JwaWinCred.pas
上传用户:davidchvip
上传日期:2009-07-28
资源大小:1749k
文件大小:62k
源码类别:

Windows编程

开发平台:

Delphi

  1. {******************************************************************************}
  2. {                                                                       }
  3. { Credentials Manager API interface Unit for Object Pascal                     }
  4. {                                                                       }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft          }
  6. { Corporation. All Rights Reserved.                                            }
  7. {                 }
  8. { The original file is: wincred.h, released November 2001. The original Pascal }
  9. { code is: WinCred.pas, released March 2002. The initial developer of the      }
  10. { Pascal code is Marcel van Brakel (brakelm@chello.nl).                        }
  11. {                                                                              }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001            }
  13. { Marcel van Brakel. All Rights Reserved.                                      }
  14. {                 }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
  16. {                }
  17. { You may retrieve the latest version of this file at the Project JEDI home    }
  18. { page, located at http://delphi-jedi.org or my personal homepage located at   }
  19. { http://members.chello.nl/m.vanbrakel2                                        }
  20. {                }
  21. { The contents of this file are used with permission, subject to the Mozilla   }
  22. { Public License Version 1.1 (the "License"); you may not use this file except }
  23. { in compliance with the License. You may obtain a copy of the License at      }
  24. { http://www.mozilla.org/MPL/MPL-1.1.html                                      }
  25. {                                                                              }
  26. { Software distributed under the License is distributed on an "AS IS" basis,   }
  27. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  28. { the specific language governing rights and limitations under the License.    }
  29. {                                                                              }
  30. { Alternatively, the contents of this file may be used under the terms of the  }
  31. { GNU Lesser General Public License (the  "LGPL License"), in which case the   }
  32. { provisions of the LGPL License are applicable instead of those above.        }
  33. { If you wish to allow use of your version of this file only under the terms   }
  34. { of the LGPL License and not to allow others to use your version of this file }
  35. { under the MPL, indicate your decision by deleting  the provisions above and  }
  36. { replace  them with the notice and other provisions required by the LGPL      }
  37. { License.  If you do not delete the provisions above, a recipient may use     }
  38. { your version of this file under either the MPL or the LGPL License.          }
  39. {                 }
  40. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  41. {                 }
  42. {******************************************************************************}
  43. unit JwaWinCred;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "wincred.h"'}
  47. {$HPPEMIT ''}
  48. {$I WINDEFINES.INC}
  49. interface
  50. uses
  51.   JwaLmCons, JwaWinBase, JwaWinError, JwaWinType, JwaNtSecApi;
  52. type
  53.   PCtxtHandle = PSecHandle;
  54.   {$EXTERNALSYM PCtxtHandle}
  55. //-----------------------------------------------------------------------------
  56. // Macros
  57. //-----------------------------------------------------------------------------
  58. //
  59. // Macro to determine whether CredUIPromptForCredentials should be called upon a failed
  60. //      authentication attempt.
  61. //
  62. // Implemented as a macro so that the caller can delay load credui.dll only if this
  63. //      macro returns TRUE.
  64. //
  65. // Include only status codes that imply the username/password are wrong or that the
  66. //      password is expired.  In the former case, asking for a another username or password
  67. //      is appropriate.  In the later case, we put up a different dialog asking the
  68. //      user to change the password on the server.
  69. //
  70. // Don't include status codes such as ERROR_ACCOUNT_DISABLED, ERROR_ACCOUNT_RESTRICTION,
  71. //      ERROR_ACCOUNT_LOCKED_OUT, ERROR_ACCOUNT_EXPIRED, ERROR_LOGON_TYPE_NOT_GRANTED.
  72. //      For those, the user isn't going to have another account so prompting him
  73. //      won't help.
  74. //
  75. // STATUS_DOWNGRADE_DETECTED is included to handle the case where a corporate laptop
  76. //      is brought to another LAN.  A downgrade attack will indeed be detected,
  77. //      but we want to popup UI to allow the user to connect to resources in the
  78. //      other LAN.
  79. //
  80. // Don't use the CREDUIP_* macros directly.  Their definition is private to credui.dll.
  81. //
  82. // Don't require ntstatus.h
  83. const
  84.   STATUS_LOGON_FAILURE          = NTSTATUS($C000006D); // ntsubauth
  85.   {$EXTERNALSYM STATUS_LOGON_FAILURE}
  86.   STATUS_WRONG_PASSWORD         = NTSTATUS($C000006A); // ntsubauth
  87.   {$EXTERNALSYM STATUS_WRONG_PASSWORD}
  88.   STATUS_PASSWORD_EXPIRED       = NTSTATUS($C0000071); // ntsubauth
  89.   {$EXTERNALSYM STATUS_PASSWORD_EXPIRED}
  90.   STATUS_PASSWORD_MUST_CHANGE   = NTSTATUS($C0000224); // ntsubauth
  91.   {$EXTERNALSYM STATUS_PASSWORD_MUST_CHANGE}
  92.   STATUS_ACCESS_DENIED          = NTSTATUS($C0000022);
  93.   {$EXTERNALSYM STATUS_ACCESS_DENIED}
  94.   STATUS_DOWNGRADE_DETECTED     = NTSTATUS($C0000388);
  95.   {$EXTERNALSYM STATUS_DOWNGRADE_DETECTED}
  96.   STATUS_AUTHENTICATION_FIREWALL_FAILED = NTSTATUS($C0000413);
  97.   {$EXTERNALSYM STATUS_AUTHENTICATION_FIREWALL_FAILED}
  98.   STATUS_ACCOUNT_DISABLED       = NTSTATUS($C0000072);   // ntsubauth
  99.   {$EXTERNALSYM STATUS_ACCOUNT_DISABLED}
  100.   STATUS_ACCOUNT_RESTRICTION    = NTSTATUS($C000006E);   // ntsubauth
  101.   {$EXTERNALSYM STATUS_ACCOUNT_RESTRICTION}
  102.   STATUS_ACCOUNT_LOCKED_OUT     = NTSTATUS($C0000234);   // ntsubauth
  103.   {$EXTERNALSYM STATUS_ACCOUNT_LOCKED_OUT}
  104.   STATUS_ACCOUNT_EXPIRED        = NTSTATUS($C0000193);   // ntsubauth
  105.   {$EXTERNALSYM STATUS_ACCOUNT_EXPIRED}
  106.   STATUS_LOGON_TYPE_NOT_GRANTED = NTSTATUS($C000015B);
  107.   {$EXTERNALSYM STATUS_LOGON_TYPE_NOT_GRANTED}
  108. // Don't require lmerr.h
  109.   NERR_BASE            = 2100;
  110.   {$EXTERNALSYM NERR_BASE}
  111.   NERR_PasswordExpired = (NERR_BASE+142); // The password of this user has expired.
  112.   {$EXTERNALSYM NERR_PasswordExpired}
  113. function CREDUIP_IS_USER_PASSWORD_ERROR(_Status: NTSTATUS): BOOL;
  114. {$EXTERNALSYM CREDUIP_IS_USER_PASSWORD_ERROR}
  115. function CREDUIP_IS_DOWNGRADE_ERROR(_Status: NTSTATUS): BOOL;
  116. {$EXTERNALSYM CREDUIP_IS_DOWNGRADE_ERROR}
  117. function CREDUIP_IS_EXPIRED_ERROR(_Status: NTSTATUS): BOOL;
  118. {$EXTERNALSYM CREDUIP_IS_EXPIRED_ERROR}
  119. function CREDUI_IS_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  120. {$EXTERNALSYM CREDUI_IS_AUTHENTICATION_ERROR}
  121. function CREDUI_NO_PROMPT_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  122. {$EXTERNALSYM CREDUI_NO_PROMPT_AUTHENTICATION_ERROR}
  123. //-----------------------------------------------------------------------------
  124. // Structures
  125. //-----------------------------------------------------------------------------
  126. //
  127. // Credential Attribute
  128. //
  129. const
  130. // Maximum length of the various credential string fields (in characters)
  131.   CRED_MAX_STRING_LENGTH = 256;
  132.   {$EXTERNALSYM CRED_MAX_STRING_LENGTH}
  133. // Maximum length of the UserName field.  The worst case is <User>@<DnsDomain>
  134.   CRED_MAX_USERNAME_LENGTH = (256+1+256);
  135.   {$EXTERNALSYM CRED_MAX_USERNAME_LENGTH}
  136. // Maximum length of the TargetName field for CRED_TYPE_GENERIC (in characters)
  137.   CRED_MAX_GENERIC_TARGET_NAME_LENGTH = 32767;
  138.   {$EXTERNALSYM CRED_MAX_GENERIC_TARGET_NAME_LENGTH}
  139. // Maximum length of the TargetName field for CRED_TYPE_DOMAIN_* (in characters)
  140. //      Largest one is <DfsRoot><DfsShare>
  141.   CRED_MAX_DOMAIN_TARGET_NAME_LENGTH = (256+1+80);
  142.   {$EXTERNALSYM CRED_MAX_DOMAIN_TARGET_NAME_LENGTH}
  143. // Maximum size of the Credential Attribute Value field (in bytes)
  144.   CRED_MAX_VALUE_SIZE = 256;
  145.   {$EXTERNALSYM CRED_MAX_VALUE_SIZE}
  146. // Maximum number of attributes per credential
  147.   CRED_MAX_ATTRIBUTES = 64;
  148.   {$EXTERNALSYM CRED_MAX_ATTRIBUTES}
  149. type
  150.   PCREDENTIAL_ATTRIBUTEA = ^CREDENTIAL_ATTRIBUTEA;
  151.   {$EXTERNALSYM PCREDENTIAL_ATTRIBUTEA}
  152.   _CREDENTIAL_ATTRIBUTEA = record
  153.     Keyword: LPSTR;
  154.     Flags: DWORD;
  155.     ValueSize: DWORD;
  156.     Value: LPBYTE;
  157.   end;
  158.   {$EXTERNALSYM _CREDENTIAL_ATTRIBUTEA}
  159.   CREDENTIAL_ATTRIBUTEA = _CREDENTIAL_ATTRIBUTEA;
  160.   {$EXTERNALSYM CREDENTIAL_ATTRIBUTEA}
  161.   TCredentialAttributeA = CREDENTIAL_ATTRIBUTEA;
  162.   PCredentialAttributeA = PCREDENTIAL_ATTRIBUTEA;
  163.   PCREDENTIAL_ATTRIBUTEW = ^CREDENTIAL_ATTRIBUTEW;
  164.   {$EXTERNALSYM PCREDENTIAL_ATTRIBUTEW}
  165.   _CREDENTIAL_ATTRIBUTEW = record
  166.     Keyword: LPWSTR;
  167.     Flags: DWORD;
  168.     ValueSize: DWORD;
  169.     Value: LPBYTE;
  170.   end;
  171.   {$EXTERNALSYM _CREDENTIAL_ATTRIBUTEW}
  172.   CREDENTIAL_ATTRIBUTEW = _CREDENTIAL_ATTRIBUTEW;
  173.   {$EXTERNALSYM CREDENTIAL_ATTRIBUTEW}
  174.   TCredentialAttributeW = CREDENTIAL_ATTRIBUTEW;
  175.   PCredentialAttributeW = PCREDENTIAL_ATTRIBUTEW;
  176. {$IFDEF UNICODE}
  177.   CREDENTIAL_ATTRIBUTE = CREDENTIAL_ATTRIBUTEW;
  178.   {$EXTERNALSYM CREDENTIAL_ATTRIBUTE}
  179.   PCREDENTIAL_ATTRIBUTE = PCREDENTIAL_ATTRIBUTEW;
  180.   {$EXTERNALSYM PCREDENTIAL_ATTRIBUTE}
  181.   TCredentialAttribute = TCredentialAttributeW;
  182.   PCredentialAttribute = PCredentialAttributeW;
  183. {$ELSE}
  184.   CREDENTIAL_ATTRIBUTE = CREDENTIAL_ATTRIBUTEA;
  185.   {$EXTERNALSYM CREDENTIAL_ATTRIBUTE}
  186.   PCREDENTIAL_ATTRIBUTE = PCREDENTIAL_ATTRIBUTEA;
  187.   {$EXTERNALSYM PCREDENTIAL_ATTRIBUTE}
  188.   TCredentialAttribute = TCredentialAttributeA;
  189.   PCredentialAttribute = PCredentialAttributeA;
  190. {$ENDIF}
  191. //
  192. // Special values of the TargetName field
  193. //
  194. const
  195.   CRED_SESSION_WILDCARD_NAME_W      = WideString('*Session');
  196.   {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME_W}
  197.   CRED_SESSION_WILDCARD_NAME_A      = '*Session';
  198.   {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME_A}
  199.   CRED_SESSION_WILDCARD_NAME_LENGTH = SizeOf(CRED_SESSION_WILDCARD_NAME_A) - 1;
  200.   {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME_LENGTH}
  201. {$IFDEF UNICODE}
  202.   CRED_SESSION_WILDCARD_NAME = CRED_SESSION_WILDCARD_NAME_W;
  203.   {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME}
  204. {$ELSE}
  205.   CRED_SESSION_WILDCARD_NAME = CRED_SESSION_WILDCARD_NAME_A;
  206.   {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME}
  207. {$ENDIF}
  208. //
  209. // Values of the Credential Flags field.
  210. //
  211. const
  212.   CRED_FLAGS_PASSWORD_FOR_CERT  = $0001;
  213.   {$EXTERNALSYM CRED_FLAGS_PASSWORD_FOR_CERT}
  214.   CRED_FLAGS_PROMPT_NOW         = $0002;
  215.   {$EXTERNALSYM CRED_FLAGS_PROMPT_NOW}
  216.   CRED_FLAGS_USERNAME_TARGET    = $0004;
  217.   {$EXTERNALSYM CRED_FLAGS_USERNAME_TARGET}
  218.   CRED_FLAGS_OWF_CRED_BLOB      = $0008;
  219.   {$EXTERNALSYM CRED_FLAGS_OWF_CRED_BLOB}
  220.   CRED_FLAGS_VALID_FLAGS        = $000F;  // Mask of all valid flags
  221.   {$EXTERNALSYM CRED_FLAGS_VALID_FLAGS}
  222. //
  223. // Values of the Credential Type field.
  224. //
  225.   CRED_TYPE_GENERIC                 = 1;
  226.   {$EXTERNALSYM CRED_TYPE_GENERIC}
  227.   CRED_TYPE_DOMAIN_PASSWORD         = 2;
  228.   {$EXTERNALSYM CRED_TYPE_DOMAIN_PASSWORD}
  229.   CRED_TYPE_DOMAIN_CERTIFICATE      = 3;
  230.   {$EXTERNALSYM CRED_TYPE_DOMAIN_CERTIFICATE}
  231.   CRED_TYPE_DOMAIN_VISIBLE_PASSWORD = 4;
  232.   {$EXTERNALSYM CRED_TYPE_DOMAIN_VISIBLE_PASSWORD}
  233.   CRED_TYPE_MAXIMUM                 = 5; // Maximum supported cred type
  234.   {$EXTERNALSYM CRED_TYPE_MAXIMUM}
  235.   CRED_TYPE_MAXIMUM_EX              = (CRED_TYPE_MAXIMUM+1000);  // Allow new applications to run on old OSes
  236.   {$EXTERNALSYM CRED_TYPE_MAXIMUM_EX}
  237. //
  238. // Maximum size of the CredBlob field (in bytes)
  239. //
  240.   CRED_MAX_CREDENTIAL_BLOB_SIZE = 512;
  241.   {$EXTERNALSYM CRED_MAX_CREDENTIAL_BLOB_SIZE}
  242. //
  243. // Values of the Credential Persist field
  244. //
  245.   CRED_PERSIST_NONE          = 0;
  246.   {$EXTERNALSYM CRED_PERSIST_NONE}
  247.   CRED_PERSIST_SESSION       = 1;
  248.   {$EXTERNALSYM CRED_PERSIST_SESSION}
  249.   CRED_PERSIST_LOCAL_MACHINE = 2;
  250.   {$EXTERNALSYM CRED_PERSIST_LOCAL_MACHINE}
  251.   CRED_PERSIST_ENTERPRISE    = 3;
  252.   {$EXTERNALSYM CRED_PERSIST_ENTERPRISE}
  253. //
  254. // A credential
  255. //
  256. type
  257.   PCREDENTIALA = ^CREDENTIALA;
  258.   {$EXTERNALSYM PCREDENTIALA}
  259.   _CREDENTIALA = record
  260.     Flags: DWORD;
  261.     Type_: DWORD;
  262.     TargetName: LPSTR;
  263.     Comment: LPSTR;
  264.     LastWritten: FILETIME;
  265.     CredentialBlobSize: DWORD;
  266.     CredentialBlob: LPBYTE;
  267.     Persist: DWORD;
  268.     AttributeCount: DWORD;
  269.     Attributes: PCREDENTIAL_ATTRIBUTEA;
  270.     TargetAlias: LPSTR;
  271.     UserName: LPSTR;
  272.   end;
  273.   {$EXTERNALSYM _CREDENTIALA}
  274.   CREDENTIALA = _CREDENTIALA;
  275.   {$EXTERNALSYM CREDENTIALA}
  276.   TCredentialA = CREDENTIALA;
  277.   PCREDENTIALW = ^CREDENTIALW;
  278.   {$EXTERNALSYM PCREDENTIALW}
  279.   _CREDENTIALW = record
  280.     Flags: DWORD;
  281.     Type_: DWORD;
  282.     TargetName: LPWSTR;
  283.     Comment: LPWSTR;
  284.     LastWritten: FILETIME;
  285.     CredentialBlobSize: DWORD;
  286.     CredentialBlob: LPBYTE;
  287.     Persist: DWORD;
  288.     AttributeCount: DWORD;
  289.     Attributes: PCREDENTIAL_ATTRIBUTEW;
  290.     TargetAlias: LPWSTR;
  291.     UserName: LPWSTR;
  292.   end;
  293.   {$EXTERNALSYM _CREDENTIALW}
  294.   CREDENTIALW = _CREDENTIALW;
  295.   {$EXTERNALSYM CREDENTIALW}
  296.   TCredentialW = CREDENTIALW;
  297. {$IFDEF UNICODE}
  298.   CREDENTIAL = CREDENTIALW;
  299.   {$EXTERNALSYM CREDENTIAL}
  300.   PCREDENTIAL = PCREDENTIALW;
  301.   {$EXTERNALSYM PCREDENTIAL}
  302.   TCredential = TCredentialW;
  303. {$ELSE}
  304.   CREDENTIAL = CREDENTIALA;
  305.   {$EXTERNALSYM CREDENTIAL}
  306.   PCREDENTIAL = PCREDENTIALA;
  307.   {$EXTERNALSYM PCREDENTIAL}
  308.   TCredential = TCredentialA;
  309. {$ENDIF}
  310. //
  311. // Value of the Flags field in CREDENTIAL_TARGET_INFORMATION
  312. //
  313. const
  314.   CRED_TI_SERVER_FORMAT_UNKNOWN  = $0001; // Don't know if server name is DNS or netbios format
  315.   {$EXTERNALSYM CRED_TI_SERVER_FORMAT_UNKNOWN}
  316.   CRED_TI_DOMAIN_FORMAT_UNKNOWN  = $0002; // Don't know if domain name is DNS or netbios format
  317.   {$EXTERNALSYM CRED_TI_DOMAIN_FORMAT_UNKNOWN}
  318.   CRED_TI_ONLY_PASSWORD_REQUIRED = $0004; // Server only requires a password and not a username
  319.   {$EXTERNALSYM CRED_TI_ONLY_PASSWORD_REQUIRED}
  320.   CRED_TI_USERNAME_TARGET        = $0008; // TargetName is username
  321.   {$EXTERNALSYM CRED_TI_USERNAME_TARGET}
  322.   CRED_TI_CREATE_EXPLICIT_CRED   = $0010; // When creating a cred, create one named TargetInfo->TargetName
  323.   {$EXTERNALSYM CRED_TI_CREATE_EXPLICIT_CRED}
  324.   CRED_TI_WORKGROUP_MEMBER       = $0020; // Indicates the machine is a member of a workgroup
  325.   {$EXTERNALSYM CRED_TI_WORKGROUP_MEMBER}
  326.   CRED_TI_VALID_FLAGS            = $003F;
  327.   {$EXTERNALSYM CRED_TI_VALID_FLAGS}
  328. //
  329. // A credential target
  330. //
  331. type
  332.   PCREDENTIAL_TARGET_INFORMATIONA = ^CREDENTIAL_TARGET_INFORMATIONA;
  333.   {$EXTERNALSYM PCREDENTIAL_TARGET_INFORMATIONA}
  334.   _CREDENTIAL_TARGET_INFORMATIONA = record
  335.     TargetName: LPSTR;
  336.     NetbiosServerName: LPSTR;
  337.     DnsServerName: LPSTR;
  338.     NetbiosDomainName: LPSTR;
  339.     DnsDomainName: LPSTR;
  340.     DnsTreeName: LPSTR;
  341.     PackageName: LPSTR;
  342.     Flags: ULONG;
  343.     CredTypeCount: DWORD;
  344.     CredTypes: LPDWORD;
  345.   end;
  346.   {$EXTERNALSYM _CREDENTIAL_TARGET_INFORMATIONA}
  347.   CREDENTIAL_TARGET_INFORMATIONA = _CREDENTIAL_TARGET_INFORMATIONA;
  348.   {$EXTERNALSYM CREDENTIAL_TARGET_INFORMATIONA}
  349.   TCredentialTargetInformationA = CREDENTIAL_TARGET_INFORMATIONA;
  350.   PCredentialTargetInformationA = PCREDENTIAL_TARGET_INFORMATIONA;
  351.   PCREDENTIAL_TARGET_INFORMATIONW = ^CREDENTIAL_TARGET_INFORMATIONW;
  352.   {$EXTERNALSYM PCREDENTIAL_TARGET_INFORMATIONW}
  353.   _CREDENTIAL_TARGET_INFORMATIONW = record
  354.     TargetName: LPWSTR;
  355.     NetbiosServerName: LPWSTR;
  356.     DnsServerName: LPWSTR;
  357.     NetbiosDomainName: LPWSTR;
  358.     DnsDomainName: LPWSTR;
  359.     DnsTreeName: LPWSTR;
  360.     PackageName: LPWSTR;
  361.     Flags: ULONG;
  362.     CredTypeCount: DWORD;
  363.     CredTypes: LPDWORD;
  364.   end;
  365.   {$EXTERNALSYM _CREDENTIAL_TARGET_INFORMATIONW}
  366.   CREDENTIAL_TARGET_INFORMATIONW = _CREDENTIAL_TARGET_INFORMATIONW;
  367.   {$EXTERNALSYM CREDENTIAL_TARGET_INFORMATIONW}
  368.   TCredentialTargetInformationW = CREDENTIAL_TARGET_INFORMATIONW;
  369.   PCredentialTargetInformationW = PCREDENTIAL_TARGET_INFORMATIONW;
  370. {$IFDEF UNICODE}
  371.   CREDENTIAL_TARGET_INFORMATION = CREDENTIAL_TARGET_INFORMATIONW;
  372.   {$EXTERNALSYM CREDENTIAL_TARGET_INFORMATION}
  373.   PCREDENTIAL_TARGET_INFORMATION = PCREDENTIAL_TARGET_INFORMATIONW;
  374.   {$EXTERNALSYM PCREDENTIAL_TARGET_INFORMATION}
  375.   TCredentialTargetInformation = TCredentialTargetInformationW;
  376.   PCredentialTargetInformation = PCredentialTargetInformationW;
  377. {$ELSE}
  378.   CREDENTIAL_TARGET_INFORMATION = CREDENTIAL_TARGET_INFORMATIONA;
  379.   {$EXTERNALSYM CREDENTIAL_TARGET_INFORMATION}
  380.   PCREDENTIAL_TARGET_INFORMATION = PCREDENTIAL_TARGET_INFORMATIONA;
  381.   {$EXTERNALSYM PCREDENTIAL_TARGET_INFORMATION}
  382.   TCredentialTargetInformation = TCredentialTargetInformationA;
  383.   PCredentialTargetInformation = PCredentialTargetInformationA;
  384. {$ENDIF}
  385. //
  386. // Certificate credential information
  387. //
  388. // The cbSize should be the size of the structure, sizeof(CERT_CREDENTIAL_INFO),
  389. // rgbHashofCert is the hash of the cert which is to be used as the credential.
  390. //
  391. const
  392.   CERT_HASH_LENGTH = 20; // SHA1 hashes are used for cert hashes
  393.   {$EXTERNALSYM CERT_HASH_LENGTH}
  394. type
  395.   PCERT_CREDENTIAL_INFO = ^CERT_CREDENTIAL_INFO;
  396.   {$EXTERNALSYM PCERT_CREDENTIAL_INFO}
  397.   _CERT_CREDENTIAL_INFO = record
  398.     cbSize: ULONG;
  399.     rgbHashOfCert: array [0..CERT_HASH_LENGTH - 1] of UCHAR;
  400.   end;
  401.   {$EXTERNALSYM _CERT_CREDENTIAL_INFO}
  402.   CERT_CREDENTIAL_INFO = _CERT_CREDENTIAL_INFO;
  403.   {$EXTERNALSYM CERT_CREDENTIAL_INFO}
  404.   TCertCredentialInfo = CERT_CREDENTIAL_INFO;
  405.   PCertCredentialInfo = PCERT_CREDENTIAL_INFO;
  406. //
  407. // Username Target credential information
  408. //
  409. // This credential can be pass to LsaLogonUser to ask it to find a credential with a
  410. // TargetName of UserName.
  411. //
  412.   PUSERNAME_TARGET_CREDENTIAL_INFO = ^USERNAME_TARGET_CREDENTIAL_INFO;
  413.   {$EXTERNALSYM PUSERNAME_TARGET_CREDENTIAL_INFO}
  414.   _USERNAME_TARGET_CREDENTIAL_INFO = record
  415.     UserName: LPWSTR;
  416.   end;
  417.   {$EXTERNALSYM _USERNAME_TARGET_CREDENTIAL_INFO}
  418.   USERNAME_TARGET_CREDENTIAL_INFO = _USERNAME_TARGET_CREDENTIAL_INFO;
  419.   {$EXTERNALSYM USERNAME_TARGET_CREDENTIAL_INFO}
  420.   TUsernameTargetCredentialInfo = USERNAME_TARGET_CREDENTIAL_INFO;
  421.   PUsernameTargetCredentialInfo = PUSERNAME_TARGET_CREDENTIAL_INFO;
  422. //
  423. // Credential type for credential marshaling routines
  424. //
  425.   _CRED_MARSHAL_TYPE = DWORD;
  426.   {$EXTERNALSYM _CRED_MARSHAL_TYPE}
  427.   CRED_MARSHAL_TYPE = _CRED_MARSHAL_TYPE;
  428.   {$EXTERNALSYM CRED_MARSHAL_TYPE}
  429.   PCRED_MARSHAL_TYPE = ^CRED_MARSHAL_TYPE;
  430.   {$EXTERNALSYM PCRED_MARSHAL_TYPE}
  431.   TCredMarshalType = CRED_MARSHAL_TYPE;
  432.   PCredMarshalType = PCRED_MARSHAL_TYPE;
  433. const
  434.   CertCredential = 1;
  435.   {$EXTERNALSYM CertCredential}
  436.   UsernameTargetCredential = 2;
  437.   {$EXTERNALSYM UsernameTargetCredential}
  438. //
  439. // Credential UI info
  440. //
  441. type
  442.   PCREDUI_INFOA = ^CREDUI_INFOA;
  443.   {$EXTERNALSYM PCREDUI_INFOA}
  444.   _CREDUI_INFOA = record
  445.     cbSize: DWORD;
  446.     hwndParent: HWND;
  447.     pszMessageText: PCSTR;
  448.     pszCaptionText: PCSTR;
  449.     hbmBanner: HBITMAP;
  450.   end;
  451.   {$EXTERNALSYM _CREDUI_INFOA}
  452.   CREDUI_INFOA = _CREDUI_INFOA;
  453.   {$EXTERNALSYM CREDUI_INFOA}
  454.   TCredUIInfoA = CREDUI_INFOA;
  455.   PCredUIInfoA = PCREDUI_INFOA;
  456.   PCREDUI_INFOW = ^CREDUI_INFOW;
  457.   {$EXTERNALSYM PCREDUI_INFOW}
  458.   _CREDUI_INFOW = record
  459.     cbSize: DWORD;
  460.     hwndParent: HWND;
  461.     pszMessageText: LPCWSTR;
  462.     pszCaptionText: LPCWSTR;
  463.     hbmBanner: HBITMAP;
  464.   end;
  465.   {$EXTERNALSYM _CREDUI_INFOW}
  466.   CREDUI_INFOW = _CREDUI_INFOW;
  467.   {$EXTERNALSYM CREDUI_INFOW}
  468.   TCredUIInfoW = CREDUI_INFOW;
  469.   PCredUIInfoW = PCREDUI_INFOW;
  470. {$IFDEF UNICODE}
  471.   CREDUI_INFO = CREDUI_INFOW;
  472.   {$EXTERNALSYM CREDUI_INFO}
  473.   PCREDUI_INFO = PCREDUI_INFOW;
  474.   {$EXTERNALSYM PCREDUI_INFO}
  475.   TCredUIInfo = TCredUIInfoW;
  476.   PCredUIInfo = PCredUIInfoW;
  477. {$ELSE}
  478.   CREDUI_INFO = CREDUI_INFOA;
  479.   {$EXTERNALSYM CREDUI_INFO}
  480.   PCREDUI_INFO = PCREDUI_INFOA;
  481.   {$EXTERNALSYM PCREDUI_INFO}
  482.   TCredUIInfo = TCredUIInfoA;
  483.   PCredUIInfo = PCredUIInfoA;
  484. {$ENDIF}
  485. //-----------------------------------------------------------------------------
  486. // Values
  487. //-----------------------------------------------------------------------------
  488. // String length limits:
  489. const
  490.   CREDUI_MAX_MESSAGE_LENGTH        = 32767;
  491.   {$EXTERNALSYM CREDUI_MAX_MESSAGE_LENGTH}
  492.   CREDUI_MAX_CAPTION_LENGTH        = 128;
  493.   {$EXTERNALSYM CREDUI_MAX_CAPTION_LENGTH}
  494.   CREDUI_MAX_GENERIC_TARGET_LENGTH = CRED_MAX_GENERIC_TARGET_NAME_LENGTH;
  495.   {$EXTERNALSYM CREDUI_MAX_GENERIC_TARGET_LENGTH}
  496.   CREDUI_MAX_DOMAIN_TARGET_LENGTH  = CRED_MAX_DOMAIN_TARGET_NAME_LENGTH;
  497.   {$EXTERNALSYM CREDUI_MAX_DOMAIN_TARGET_LENGTH}
  498.   CREDUI_MAX_USERNAME_LENGTH       = CRED_MAX_USERNAME_LENGTH;
  499.   {$EXTERNALSYM CREDUI_MAX_USERNAME_LENGTH}
  500.   CREDUI_MAX_PASSWORD_LENGTH       = (CRED_MAX_CREDENTIAL_BLOB_SIZE div 2);
  501.   {$EXTERNALSYM CREDUI_MAX_PASSWORD_LENGTH}
  502. //
  503. // Flags for CredUIPromptForCredentials and/or CredUICmdLinePromptForCredentials
  504. //
  505.   CREDUI_FLAGS_INCORRECT_PASSWORD          = $00001; // indicates the username is valid, but password is not
  506.   {$EXTERNALSYM CREDUI_FLAGS_INCORRECT_PASSWORD}
  507.   CREDUI_FLAGS_DO_NOT_PERSIST              = $00002; // Do not show "Save" checkbox, and do not persist credentials
  508.   {$EXTERNALSYM CREDUI_FLAGS_DO_NOT_PERSIST}
  509.   CREDUI_FLAGS_REQUEST_ADMINISTRATOR       = $00004; // Populate list box with admin accounts
  510.   {$EXTERNALSYM CREDUI_FLAGS_REQUEST_ADMINISTRATOR}
  511.   CREDUI_FLAGS_EXCLUDE_CERTIFICATES        = $00008; // do not include certificates in the drop list
  512.   {$EXTERNALSYM CREDUI_FLAGS_EXCLUDE_CERTIFICATES}
  513.   CREDUI_FLAGS_REQUIRE_CERTIFICATE         = $00010;
  514.   {$EXTERNALSYM CREDUI_FLAGS_REQUIRE_CERTIFICATE}
  515.   CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX         = $00040;
  516.   {$EXTERNALSYM CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX}
  517.   CREDUI_FLAGS_ALWAYS_SHOW_UI              = $00080;
  518.   {$EXTERNALSYM CREDUI_FLAGS_ALWAYS_SHOW_UI}
  519.   CREDUI_FLAGS_REQUIRE_SMARTCARD           = $00100;
  520.   {$EXTERNALSYM CREDUI_FLAGS_REQUIRE_SMARTCARD}
  521.   CREDUI_FLAGS_PASSWORD_ONLY_OK            = $00200;
  522.   {$EXTERNALSYM CREDUI_FLAGS_PASSWORD_ONLY_OK}
  523.   CREDUI_FLAGS_VALIDATE_USERNAME           = $00400;
  524.   {$EXTERNALSYM CREDUI_FLAGS_VALIDATE_USERNAME}
  525.   CREDUI_FLAGS_COMPLETE_USERNAME           = $00800;
  526.   {$EXTERNALSYM CREDUI_FLAGS_COMPLETE_USERNAME}
  527.   CREDUI_FLAGS_PERSIST                     = $01000; // Do not show "Save" checkbox, but persist credentials anyway
  528.   {$EXTERNALSYM CREDUI_FLAGS_PERSIST}
  529.   CREDUI_FLAGS_SERVER_CREDENTIAL           = $04000;
  530.   {$EXTERNALSYM CREDUI_FLAGS_SERVER_CREDENTIAL}
  531.   CREDUI_FLAGS_EXPECT_CONFIRMATION         = $20000; // do not persist unless caller later confirms credential via CredUIConfirmCredential() api
  532.   {$EXTERNALSYM CREDUI_FLAGS_EXPECT_CONFIRMATION}
  533.   CREDUI_FLAGS_GENERIC_CREDENTIALS         = $40000; // Credential is a generic credential
  534.   {$EXTERNALSYM CREDUI_FLAGS_GENERIC_CREDENTIALS}
  535.   CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS = $80000; // Credential has a username as the target
  536.   {$EXTERNALSYM CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS}
  537.   CREDUI_FLAGS_KEEP_USERNAME               = $100000; // don't allow the user to change the supplied username
  538.   {$EXTERNALSYM CREDUI_FLAGS_KEEP_USERNAME}
  539. //
  540. // Mask of flags valid for CredUIPromptForCredentials
  541. //
  542.   CREDUI_FLAGS_PROMPT_VALID =
  543.     CREDUI_FLAGS_INCORRECT_PASSWORD or
  544.     CREDUI_FLAGS_DO_NOT_PERSIST or
  545.     CREDUI_FLAGS_REQUEST_ADMINISTRATOR or
  546.     CREDUI_FLAGS_EXCLUDE_CERTIFICATES or
  547.     CREDUI_FLAGS_REQUIRE_CERTIFICATE or
  548.     CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX or
  549.     CREDUI_FLAGS_ALWAYS_SHOW_UI or
  550.     CREDUI_FLAGS_REQUIRE_SMARTCARD or
  551.     CREDUI_FLAGS_PASSWORD_ONLY_OK or
  552.     CREDUI_FLAGS_VALIDATE_USERNAME or
  553.     CREDUI_FLAGS_COMPLETE_USERNAME or
  554.     CREDUI_FLAGS_PERSIST or
  555.     CREDUI_FLAGS_SERVER_CREDENTIAL or
  556.     CREDUI_FLAGS_EXPECT_CONFIRMATION or
  557.     CREDUI_FLAGS_GENERIC_CREDENTIALS or
  558.     CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS or
  559.     CREDUI_FLAGS_KEEP_USERNAME;
  560.   {$EXTERNALSYM CREDUI_FLAGS_PROMPT_VALID}
  561. //-----------------------------------------------------------------------------
  562. // Functions
  563. //-----------------------------------------------------------------------------
  564. //
  565. // Values of flags to CredWrite and CredWriteDomainCredentials
  566. //
  567. const
  568.   CRED_PRESERVE_CREDENTIAL_BLOB = $1;
  569.   {$EXTERNALSYM CRED_PRESERVE_CREDENTIAL_BLOB}
  570. function CredWriteW(Credential: PCREDENTIALW; Flags: DWORD): BOOL; stdcall;
  571. {$EXTERNALSYM CredWriteW}
  572. function CredWriteA(Credential: PCREDENTIALA; Flags: DWORD): BOOL; stdcall;
  573. {$EXTERNALSYM CredWriteA}
  574. {$IFDEF UNICODE}
  575. function CredWrite(Credential: PCREDENTIALW; Flags: DWORD): BOOL; stdcall;
  576. {$EXTERNALSYM CredWrite}
  577. {$ELSE}
  578. function CredWrite(Credential: PCREDENTIALA; Flags: DWORD): BOOL; stdcall;
  579. {$EXTERNALSYM CredWrite}
  580. {$ENDIF}
  581. function CredReadW(TargetName: LPCWSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  582. {$EXTERNALSYM CredReadW}
  583. function CredReadA(TargetName: LPCSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  584. {$EXTERNALSYM CredReadA}
  585. {$IFDEF UNICODE}
  586. function CredRead(TargetName: LPCWSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  587. {$EXTERNALSYM CredRead}
  588. {$ELSE}
  589. function CredRead(TargetName: LPCSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  590. {$EXTERNALSYM CredRead}
  591. {$ENDIF}
  592. function CredEnumerateW(Filter: LPCWSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  593. {$EXTERNALSYM CredEnumerateW}
  594. function CredEnumerateA(Filter: LPCSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  595. {$EXTERNALSYM CredEnumerateA}
  596. {$IFDEF UNICODE}
  597. function CredEnumerate(Filter: LPCWSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  598. {$EXTERNALSYM CredEnumerate}
  599. {$ELSE}
  600. function CredEnumerate(Filter: LPCSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  601. {$EXTERNALSYM CredEnumerate}
  602. {$ENDIF}
  603. function CredWriteDomainCredentialsW(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW; Credential: PCREDENTIALW; Flags: DWORD): BOOL; stdcall;
  604. {$EXTERNALSYM CredWriteDomainCredentialsW}
  605. function CredWriteDomainCredentialsA(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA; Credential: PCREDENTIALA; Flags: DWORD): BOOL; stdcall;
  606. {$EXTERNALSYM CredWriteDomainCredentialsA}
  607. {$IFDEF UNICODE}
  608. function CredWriteDomainCredentials(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW; Credential: PCREDENTIALW; Flags: DWORD): BOOL; stdcall;
  609. {$EXTERNALSYM CredWriteDomainCredentials}
  610. {$ELSE}
  611. function CredWriteDomainCredentials(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA; Credential: PCREDENTIALA; Flags: DWORD): BOOL; stdcall;
  612. {$EXTERNALSYM CredWriteDomainCredentials}
  613. {$ENDIF}
  614. //
  615. // Values of flags to CredReadDomainCredentials
  616. //
  617. const
  618.   CRED_CACHE_TARGET_INFORMATION = $1;
  619.   {$EXTERNALSYM CRED_CACHE_TARGET_INFORMATION}
  620. function CredReadDomainCredentialsW(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  621. {$EXTERNALSYM CredReadDomainCredentialsW}
  622. function CredReadDomainCredentialsA(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  623. {$EXTERNALSYM CredReadDomainCredentialsA}
  624. {$IFDEF UNICODE}
  625. function CredReadDomainCredentials(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  626. {$EXTERNALSYM CredReadDomainCredentials}
  627. {$ELSE}
  628. function CredReadDomainCredentials(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  629. {$EXTERNALSYM CredReadDomainCredentials}
  630. {$ENDIF}
  631. function CredDeleteW(TargetName: LPCWSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  632. {$EXTERNALSYM CredDeleteW}
  633. function CredDeleteA(TargetName: LPCSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  634. {$EXTERNALSYM CredDeleteA}
  635. {$IFDEF UNICODE}
  636. function CredDelete(TargetName: LPCWSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  637. {$EXTERNALSYM CredDelete}
  638. {$ELSE}
  639. function CredDelete(TargetName: LPCSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  640. {$EXTERNALSYM CredDelete}
  641. {$ENDIF}
  642. function CredRenameW(OldTargetName: LPCWSTR; NewTargetName: LPCWSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  643. {$EXTERNALSYM CredRenameW}
  644. function CredRenameA(OldTargetName: LPCSTR; NewTargetName: LPCSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  645. {$EXTERNALSYM CredRenameA}
  646. {$IFDEF UNICODE}
  647. function CredRename(OldTargetName: LPCWSTR; NewTargetName: LPCWSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  648. {$EXTERNALSYM CredRename}
  649. {$ELSE}
  650. function CredRename(OldTargetName: LPCSTR; NewTargetName: LPCSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  651. {$EXTERNALSYM CredRename}
  652. {$ENDIF}
  653. //
  654. // Values of flags to CredGetTargetInfo
  655. //
  656. const
  657.   CRED_ALLOW_NAME_RESOLUTION = $1;
  658.   {$EXTERNALSYM CRED_ALLOW_NAME_RESOLUTION}
  659. function CredGetTargetInfoW(TargetName: LPCWSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW): BOOL; stdcall;
  660. {$EXTERNALSYM CredGetTargetInfoW}
  661. function CredGetTargetInfoA(TargetName: LPCSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA): BOOL; stdcall;
  662. {$EXTERNALSYM CredGetTargetInfoA}
  663. {$IFDEF UNICODE}
  664. function CredGetTargetInfo(TargetName: LPCWSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW): BOOL; stdcall;
  665. {$EXTERNALSYM CredGetTargetInfo}
  666. {$ELSE}
  667. function CredGetTargetInfo(TargetName: LPCSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA): BOOL; stdcall;
  668. {$EXTERNALSYM CredGetTargetInfo}
  669. {$ENDIF}
  670. function CredMarshalCredentialW(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; var MarshaledCredential: LPWSTR): BOOL; stdcall;
  671. {$EXTERNALSYM CredMarshalCredentialW}
  672. function CredMarshalCredentialA(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; MarshaledCredential: LPSTR): BOOL; stdcall;
  673. {$EXTERNALSYM CredMarshalCredentialA}
  674. {$IFDEF UNICODE}
  675. function CredMarshalCredential(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; var MarshaledCredential: LPWSTR): BOOL; stdcall;
  676. {$EXTERNALSYM CredMarshalCredential}
  677. {$ELSE}
  678. function CredMarshalCredential(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; MarshaledCredential: LPSTR): BOOL; stdcall;
  679. {$EXTERNALSYM CredMarshalCredential}
  680. {$ENDIF}
  681. function CredUnmarshalCredentialW(MarshaledCredential: LPCWSTR; CredType: PCRED_MARSHAL_TYPE; var Credential: PVOID): BOOL; stdcall;
  682. {$EXTERNALSYM CredUnmarshalCredentialW}
  683. function CredUnmarshalCredentialA(MarshaledCredential: LPCSTR; CredType: PCRED_MARSHAL_TYPE; Credential: PVOID): BOOL; stdcall;
  684. {$EXTERNALSYM CredUnmarshalCredentialA}
  685. {$IFDEF UNICODE}
  686. function CredUnmarshalCredential(MarshaledCredential: LPCWSTR; CredType: PCRED_MARSHAL_TYPE; var Credential: PVOID): BOOL; stdcall;
  687. {$EXTERNALSYM CredUnmarshalCredential}
  688. {$ELSE}
  689. function CredUnmarshalCredential(MarshaledCredential: LPCSTR; CredType: PCRED_MARSHAL_TYPE; Credential: PVOID): BOOL; stdcall;
  690. {$EXTERNALSYM CredUnmarshalCredential}
  691. {$ENDIF}
  692. function CredIsMarshaledCredentialW(MarshaledCredential: LPCWSTR): BOOL; stdcall;
  693. {$EXTERNALSYM CredIsMarshaledCredentialW}
  694. function CredIsMarshaledCredentialA(MarshaledCredential: LPCSTR): BOOL; stdcall;
  695. {$EXTERNALSYM CredIsMarshaledCredentialA}
  696. {$IFDEF UNICODE}
  697. function CredIsMarshaledCredential(MarshaledCredential: LPCWSTR): BOOL; stdcall;
  698. {$EXTERNALSYM CredIsMarshaledCredential}
  699. {$ELSE}
  700. function CredIsMarshaledCredential(MarshaledCredential: LPCSTR): BOOL; stdcall;
  701. {$EXTERNALSYM CredIsMarshaledCredential}
  702. {$ENDIF}
  703. function CredGetSessionTypes(MaximumPersistCount: DWORD; MaximumPersist: LPDWORD): BOOL; stdcall;
  704. {$EXTERNALSYM CredGetSessionTypes}
  705. procedure CredFree(Buffer: PVOID); stdcall;
  706. {$EXTERNALSYM CredFree}
  707. function CredUIPromptForCredentialsW(pUiInfo: PCREDUI_INFOW; pszTargetName: LPCWSTR; pContext: PCtxtHandle; dwAuthError: DWORD; pszUserName: PWSTR; ulUserNameBufferSize: ULONG; pszPassword: PWSTR; ulPasswordBufferSize: ULONG; var save: BOOL; dwFlags: DWORD): DWORD; stdcall;
  708. {$EXTERNALSYM CredUIPromptForCredentialsW}
  709. function CredUIPromptForCredentialsA(pUiInfo: PCREDUI_INFOA; pszTargetName: PCSTR; pContext: PCtxtHandle; dwAuthError: DWORD; pszUserName: PSTR; ulUserNameBufferSize: ULONG; pszPassword: PSTR; ulPasswordBufferSize: ULONG; var save: BOOL; dwFlags: DWORD): DWORD; stdcall;
  710. {$EXTERNALSYM CredUIPromptForCredentialsA}
  711. {$IFDEF UNICODE}
  712. function CredUIPromptForCredentials(pUiInfo: PCREDUI_INFOW; pszTargetName: LPCWSTR; pContext: PCtxtHandle; dwAuthError: DWORD; pszUserName: PWSTR; ulUserNameBufferSize: ULONG; pszPassword: PWSTR; ulPasswordBufferSize: ULONG; var save: BOOL; dwFlags: DWORD): DWORD; stdcall;
  713. {$EXTERNALSYM CredUIPromptForCredentials}
  714. {$ELSE}
  715. function CredUIPromptForCredentials(pUiInfo: PCREDUI_INFOA; pszTargetName: PCSTR; pContext: PCtxtHandle; dwAuthError: DWORD; pszUserName: PSTR; ulUserNameBufferSize: ULONG; pszPassword: PSTR; ulPasswordBufferSize: ULONG; var save: BOOL; dwFlags: DWORD): DWORD; stdcall;
  716. {$EXTERNALSYM CredUIPromptForCredentials}
  717. {$ENDIF}
  718. function CredUIParseUserNameW(pszUserName: LPCWSTR; pszUser: PWSTR; ulUserBufferSize: ULONG; pszDomain: PWSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  719. {$EXTERNALSYM CredUIParseUserNameW}
  720. function CredUIParseUserNameA(pszUserName: PCSTR; pszUser: PSTR; ulUserBufferSize: ULONG; pszDomain: PSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  721. {$EXTERNALSYM CredUIParseUserNameA}
  722. {$IFDEF UNICODE}
  723. function CredUIParseUserName(pszUserName: LPCWSTR; pszUser: PWSTR; ulUserBufferSize: ULONG; pszDomain: PWSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  724. {$EXTERNALSYM CredUIParseUserName}
  725. {$ELSE}
  726. function CredUIParseUserName(pszUserName: PCSTR; pszUser: PSTR; ulUserBufferSize: ULONG; pszDomain: PSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  727. {$EXTERNALSYM CredUIParseUserName}
  728. {$ENDIF}
  729. function CredUICmdLinePromptForCredentialsW(pszTargetName: LPCWSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PWSTR; ulUserBufferSize: ULONG; pszPassword: PWSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  730. {$EXTERNALSYM CredUICmdLinePromptForCredentialsW}
  731. function CredUICmdLinePromptForCredentialsA(pszTargetName: PCSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PSTR; ulUserBufferSize: ULONG; pszPassword: PSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  732. {$EXTERNALSYM CredUICmdLinePromptForCredentialsA}
  733. {$IFDEF UNICODE}
  734. function CredUICmdLinePromptForCredentials(pszTargetName: LPCWSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PWSTR; ulUserBufferSize: ULONG; pszPassword: PWSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  735. {$EXTERNALSYM CredUICmdLinePromptForCredentials}
  736. {$ELSE}
  737. function CredUICmdLinePromptForCredentials(pszTargetName: PCSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PSTR; ulUserBufferSize: ULONG; pszPassword: PSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  738. {$EXTERNALSYM CredUICmdLinePromptForCredentials}
  739. {$ENDIF}
  740. //
  741. // Call this API with bConfirm set to TRUE to confirm that the credential (previously created
  742. // via CredUIGetCredentials or CredUIPromptForCredentials worked, or with bConfirm set to FALSE
  743. // to indicate it didn't
  744. function CredUIConfirmCredentialsW(pszTargetName: LPCWSTR; bConfirm: BOOL): DWORD; stdcall;
  745. {$EXTERNALSYM CredUIConfirmCredentialsW}
  746. function CredUIConfirmCredentialsA(pszTargetName: PCSTR; bConfirm: BOOL): DWORD; stdcall;
  747. {$EXTERNALSYM CredUIConfirmCredentialsA}
  748. {$IFDEF UNICODE}
  749. function CredUIConfirmCredentials(pszTargetName: LPCWSTR; bConfirm: BOOL): DWORD; stdcall;
  750. {$EXTERNALSYM CredUIConfirmCredentials}
  751. {$ELSE}
  752. function CredUIConfirmCredentials(pszTargetName: PCSTR; bConfirm: BOOL): DWORD; stdcall;
  753. {$EXTERNALSYM CredUIConfirmCredentials}
  754. {$ENDIF}
  755. implementation
  756. function CREDUIP_IS_USER_PASSWORD_ERROR(_Status: NTSTATUS): BOOL;
  757. begin
  758.   Result :=
  759.     (DWORD(_Status) = ERROR_LOGON_FAILURE) or
  760.     (_Status = HRESULT_FROM_WIN32(ERROR_LOGON_FAILURE)) or
  761.     (_Status = STATUS_LOGON_FAILURE) or
  762.     (_Status = HRESULT_FROM_NT(STATUS_LOGON_FAILURE)) or
  763.     (DWORD(_Status) = ERROR_ACCESS_DENIED) or
  764.     (_Status = HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED)) or
  765.     (_Status = STATUS_ACCESS_DENIED) or
  766.     (_Status = HRESULT_FROM_NT(STATUS_ACCESS_DENIED)) or
  767.     (DWORD(_Status) = ERROR_INVALID_PASSWORD) or
  768.     (_Status = HRESULT_FROM_WIN32(ERROR_INVALID_PASSWORD)) or
  769.     (_Status = STATUS_WRONG_PASSWORD) or
  770.     (_Status = HRESULT_FROM_NT(STATUS_WRONG_PASSWORD)) or
  771.     (_Status = SEC_E_NO_CREDENTIALS) or
  772.     (_Status = SEC_E_LOGON_DENIED);
  773. end;
  774. function CREDUIP_IS_DOWNGRADE_ERROR(_Status: NTSTATUS): BOOL;
  775. begin
  776.   Result :=
  777.     (DWORD(_Status) = ERROR_DOWNGRADE_DETECTED) or
  778.     (_Status = HRESULT_FROM_WIN32(ERROR_DOWNGRADE_DETECTED)) or
  779.     (_Status = STATUS_DOWNGRADE_DETECTED) or
  780.     (_Status = HRESULT_FROM_NT(STATUS_DOWNGRADE_DETECTED))
  781. end;
  782. function CREDUIP_IS_EXPIRED_ERROR(_Status: NTSTATUS): BOOL;
  783. begin
  784.   Result :=
  785.     (DWORD(_Status) = ERROR_PASSWORD_EXPIRED) or
  786.     (_Status = HRESULT_FROM_WIN32( ERROR_PASSWORD_EXPIRED)) or
  787.     (_Status = STATUS_PASSWORD_EXPIRED) or
  788.     (_Status = HRESULT_FROM_NT( STATUS_PASSWORD_EXPIRED)) or
  789.     (DWORD(_Status) = ERROR_PASSWORD_MUST_CHANGE) or
  790.     (_Status = HRESULT_FROM_WIN32( ERROR_PASSWORD_MUST_CHANGE)) or
  791.     (_Status = STATUS_PASSWORD_MUST_CHANGE) or
  792.     (_Status = HRESULT_FROM_NT( STATUS_PASSWORD_MUST_CHANGE)) or
  793.     (_Status = NERR_PasswordExpired) or
  794.     (_Status = HRESULT_FROM_WIN32(NERR_PasswordExpired));
  795. end;
  796. function CREDUI_IS_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  797. begin
  798.   Result := CREDUIP_IS_USER_PASSWORD_ERROR(_Status) or CREDUIP_IS_DOWNGRADE_ERROR(_Status) or CREDUIP_IS_EXPIRED_ERROR(_Status);
  799. end;
  800. function CREDUI_NO_PROMPT_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  801. begin
  802.   Result :=
  803.     (_Status = 1935{TODO Temp until WinError updated ERROR_AUTHENTICATION_FIREWALL_FAILED}) or
  804.     (_Status = HRESULT_FROM_WIN32(1935{TODO ERROR_AUTHENTICATION_FIREWALL_FAILED})) or
  805.     (_Status = STATUS_AUTHENTICATION_FIREWALL_FAILED) or
  806.     (_Status = HRESULT_FROM_NT(STATUS_AUTHENTICATION_FIREWALL_FAILED)) or
  807.     (DWORD(_Status) = ERROR_ACCOUNT_DISABLED) or
  808.     (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_DISABLED)) or
  809.     (_Status = STATUS_ACCOUNT_DISABLED) or
  810.     (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_DISABLED)) or
  811.     (DWORD(_Status) = ERROR_ACCOUNT_RESTRICTION) or
  812.     (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_RESTRICTION)) or
  813.     (_Status = STATUS_ACCOUNT_RESTRICTION) or
  814.     (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_RESTRICTION)) or
  815.     (DWORD(_Status) = ERROR_ACCOUNT_LOCKED_OUT) or
  816.     (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_LOCKED_OUT)) or
  817.     (_Status = STATUS_ACCOUNT_LOCKED_OUT) or
  818.     (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_LOCKED_OUT)) or
  819.     (DWORD(_Status) = ERROR_ACCOUNT_EXPIRED) or
  820.     (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_EXPIRED)) or
  821.     (_Status = STATUS_ACCOUNT_EXPIRED) or
  822.     (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_EXPIRED)) or
  823.     (DWORD(_Status) = ERROR_LOGON_TYPE_NOT_GRANTED) or
  824.     (_Status = HRESULT_FROM_WIN32(ERROR_LOGON_TYPE_NOT_GRANTED)) or
  825.     (_Status = STATUS_LOGON_TYPE_NOT_GRANTED) or
  826.     (_Status = HRESULT_FROM_NT(STATUS_LOGON_TYPE_NOT_GRANTED));
  827. end;
  828. const
  829.   credapi = 'advapi32.dll';
  830.   credui = 'credui.dll';
  831. {$IFDEF DYNAMIC_LINK}
  832. var
  833.   _CredWriteW: Pointer;
  834. function CredWriteW;
  835. begin
  836.   GetProcedureAddress(_CredWriteW, credapi, 'CredWriteW');
  837.   asm
  838.     mov esp, ebp
  839.     pop ebp
  840.     jmp [_CredWriteW]
  841.   end;
  842. end;
  843. {$ELSE}
  844. function CredWriteW; external credapi name 'CredWriteW';
  845. {$ENDIF DYNAMIC_LINK}
  846. {$IFDEF DYNAMIC_LINK}
  847. var
  848.   _CredWriteA: Pointer;
  849. function CredWriteA;
  850. begin
  851.   GetProcedureAddress(_CredWriteA, credapi, 'CredWriteA');
  852.   asm
  853.     mov esp, ebp
  854.     pop ebp
  855.     jmp [_CredWriteA]
  856.   end;
  857. end;
  858. {$ELSE}
  859. function CredWriteA; external credapi name 'CredWriteA';
  860. {$ENDIF DYNAMIC_LINK}
  861. {$IFDEF UNICODE}
  862. {$IFDEF DYNAMIC_LINK}
  863. var
  864.   _CredWrite: Pointer;
  865. function CredWrite;
  866. begin
  867.   GetProcedureAddress(_CredWrite, credapi, 'CredWriteW');
  868.   asm
  869.     mov esp, ebp
  870.     pop ebp
  871.     jmp [_CredWrite]
  872.   end;
  873. end;
  874. {$ELSE}
  875. function CredWrite; external credapi name 'CredWriteW';
  876. {$ENDIF DYNAMIC_LINK}
  877. {$ELSE}
  878. {$IFDEF DYNAMIC_LINK}
  879. var
  880.   _CredWrite: Pointer;
  881. function CredWrite;
  882. begin
  883.   GetProcedureAddress(_CredWrite, credapi, 'CredWriteA');
  884.   asm
  885.     mov esp, ebp
  886.     pop ebp
  887.     jmp [_CredWrite]
  888.   end;
  889. end;
  890. {$ELSE}
  891. function CredWrite; external credapi name 'CredWriteA';
  892. {$ENDIF DYNAMIC_LINK}
  893. {$ENDIF}
  894. {$IFDEF DYNAMIC_LINK}
  895. var
  896.   _CredReadW: Pointer;
  897. function CredReadW;
  898. begin
  899.   GetProcedureAddress(_CredReadW, credapi, 'CredReadW');
  900.   asm
  901.     mov esp, ebp
  902.     pop ebp
  903.     jmp [_CredReadW]
  904.   end;
  905. end;
  906. {$ELSE}
  907. function CredReadW; external credapi name 'CredReadW';
  908. {$ENDIF DYNAMIC_LINK}
  909. {$IFDEF DYNAMIC_LINK}
  910. var
  911.   _CredReadA: Pointer;
  912. function CredReadA;
  913. begin
  914.   GetProcedureAddress(_CredReadA, credapi, 'CredReadA');
  915.   asm
  916.     mov esp, ebp
  917.     pop ebp
  918.     jmp [_CredReadA]
  919.   end;
  920. end;
  921. {$ELSE}
  922. function CredReadA; external credapi name 'CredReadA';
  923. {$ENDIF DYNAMIC_LINK}
  924. {$IFDEF UNICODE}
  925. {$IFDEF DYNAMIC_LINK}
  926. var
  927.   _CredRead: Pointer;
  928. function CredRead;
  929. begin
  930.   GetProcedureAddress(_CredRead, credapi, 'CredReadW');
  931.   asm
  932.     mov esp, ebp
  933.     pop ebp
  934.     jmp [_CredRead]
  935.   end;
  936. end;
  937. {$ELSE}
  938. function CredRead; external credapi name 'CredReadW';
  939. {$ENDIF DYNAMIC_LINK}
  940. {$ELSE}
  941. {$IFDEF DYNAMIC_LINK}
  942. var
  943.   _CredRead: Pointer;
  944. function CredRead;
  945. begin
  946.   GetProcedureAddress(_CredRead, credapi, 'CredReadA');
  947.   asm
  948.     mov esp, ebp
  949.     pop ebp
  950.     jmp [_CredRead]
  951.   end;
  952. end;
  953. {$ELSE}
  954. function CredRead; external credapi name 'CredReadA';
  955. {$ENDIF DYNAMIC_LINK}
  956. {$ENDIF}
  957. {$IFDEF DYNAMIC_LINK}
  958. var
  959.   _CredEnumerateW: Pointer;
  960. function CredEnumerateW;
  961. begin
  962.   GetProcedureAddress(_CredEnumerateW, credapi, 'CredEnumerateW');
  963.   asm
  964.     mov esp, ebp
  965.     pop ebp
  966.     jmp [_CredEnumerateW]
  967.   end;
  968. end;
  969. {$ELSE}
  970. function CredEnumerateW; external credapi name 'CredEnumerateW';
  971. {$ENDIF DYNAMIC_LINK}
  972. {$IFDEF DYNAMIC_LINK}
  973. var
  974.   _CredEnumerateA: Pointer;
  975. function CredEnumerateA;
  976. begin
  977.   GetProcedureAddress(_CredEnumerateA, credapi, 'CredEnumerateA');
  978.   asm
  979.     mov esp, ebp
  980.     pop ebp
  981.     jmp [_CredEnumerateA]
  982.   end;
  983. end;
  984. {$ELSE}
  985. function CredEnumerateA; external credapi name 'CredEnumerateA';
  986. {$ENDIF DYNAMIC_LINK}
  987. {$IFDEF UNICODE}
  988. {$IFDEF DYNAMIC_LINK}
  989. var
  990.   _CredEnumerate: Pointer;
  991. function CredEnumerate;
  992. begin
  993.   GetProcedureAddress(_CredEnumerate, credapi, 'CredEnumerateW');
  994.   asm
  995.     mov esp, ebp
  996.     pop ebp
  997.     jmp [_CredEnumerate]
  998.   end;
  999. end;
  1000. {$ELSE}
  1001. function CredEnumerate; external credapi name 'CredEnumerateW';
  1002. {$ENDIF DYNAMIC_LINK}
  1003. {$ELSE}
  1004. {$IFDEF DYNAMIC_LINK}
  1005. var
  1006.   _CredEnumerate: Pointer;
  1007. function CredEnumerate;
  1008. begin
  1009.   GetProcedureAddress(_CredEnumerate, credapi, 'CredEnumerateA');
  1010.   asm
  1011.     mov esp, ebp
  1012.     pop ebp
  1013.     jmp [_CredEnumerate]
  1014.   end;
  1015. end;
  1016. {$ELSE}
  1017. function CredEnumerate; external credapi name 'CredEnumerateA';
  1018. {$ENDIF DYNAMIC_LINK}
  1019. {$ENDIF}
  1020. {$IFDEF DYNAMIC_LINK}
  1021. var
  1022.   _CredWriteDomainCredentialsW: Pointer;
  1023. function CredWriteDomainCredentialsW;
  1024. begin
  1025.   GetProcedureAddress(_CredWriteDomainCredentialsW, credapi, 'CredWriteDomainCredentialsW');
  1026.   asm
  1027.     mov esp, ebp
  1028.     pop ebp
  1029.     jmp [_CredWriteDomainCredentialsW]
  1030.   end;
  1031. end;
  1032. {$ELSE}
  1033. function CredWriteDomainCredentialsW; external credapi name 'CredWriteDomainCredentialsW';
  1034. {$ENDIF DYNAMIC_LINK}
  1035. {$IFDEF DYNAMIC_LINK}
  1036. var
  1037.   _CredWriteDomainCredentialsA: Pointer;
  1038. function CredWriteDomainCredentialsA;
  1039. begin
  1040.   GetProcedureAddress(_CredWriteDomainCredentialsA, credapi, 'CredWriteDomainCredentialsA');
  1041.   asm
  1042.     mov esp, ebp
  1043.     pop ebp
  1044.     jmp [_CredWriteDomainCredentialsA]
  1045.   end;
  1046. end;
  1047. {$ELSE}
  1048. function CredWriteDomainCredentialsA; external credapi name 'CredWriteDomainCredentialsA';
  1049. {$ENDIF DYNAMIC_LINK}
  1050. {$IFDEF UNICODE}
  1051. {$IFDEF DYNAMIC_LINK}
  1052. var
  1053.   _CredWriteDomainCredentials: Pointer;
  1054. function CredWriteDomainCredentials;
  1055. begin
  1056.   GetProcedureAddress(_CredWriteDomainCredentials, credapi, 'CredWriteDomainCredentialsW');
  1057.   asm
  1058.     mov esp, ebp
  1059.     pop ebp
  1060.     jmp [_CredWriteDomainCredentials]
  1061.   end;
  1062. end;
  1063. {$ELSE}
  1064. function CredWriteDomainCredentials; external credapi name 'CredWriteDomainCredentialsW';
  1065. {$ENDIF DYNAMIC_LINK}
  1066. {$ELSE}
  1067. {$IFDEF DYNAMIC_LINK}
  1068. var
  1069.   _CredWriteDomainCredentials: Pointer;
  1070. function CredWriteDomainCredentials;
  1071. begin
  1072.   GetProcedureAddress(_CredWriteDomainCredentials, credapi, 'CredWriteDomainCredentialsA');
  1073.   asm
  1074.     mov esp, ebp
  1075.     pop ebp
  1076.     jmp [_CredWriteDomainCredentials]
  1077.   end;
  1078. end;
  1079. {$ELSE}
  1080. function CredWriteDomainCredentials; external credapi name 'CredWriteDomainCredentialsA';
  1081. {$ENDIF DYNAMIC_LINK}
  1082. {$ENDIF}
  1083. {$IFDEF DYNAMIC_LINK}
  1084. var
  1085.   _CredReadDomainCredentialsW: Pointer;
  1086. function CredReadDomainCredentialsW;
  1087. begin
  1088.   GetProcedureAddress(_CredReadDomainCredentialsW, credapi, 'CredReadDomainCredentialsW');
  1089.   asm
  1090.     mov esp, ebp
  1091.     pop ebp
  1092.     jmp [_CredReadDomainCredentialsW]
  1093.   end;
  1094. end;
  1095. {$ELSE}
  1096. function CredReadDomainCredentialsW; external credapi name 'CredReadDomainCredentialsW';
  1097. {$ENDIF DYNAMIC_LINK}
  1098. {$IFDEF DYNAMIC_LINK}
  1099. var
  1100.   _CredReadDomainCredentialsA: Pointer;
  1101. function CredReadDomainCredentialsA;
  1102. begin
  1103.   GetProcedureAddress(_CredReadDomainCredentialsA, credapi, 'CredReadDomainCredentialsA');
  1104.   asm
  1105.     mov esp, ebp
  1106.     pop ebp
  1107.     jmp [_CredReadDomainCredentialsA]
  1108.   end;
  1109. end;
  1110. {$ELSE}
  1111. function CredReadDomainCredentialsA; external credapi name 'CredReadDomainCredentialsA';
  1112. {$ENDIF DYNAMIC_LINK}
  1113. {$IFDEF UNICODE}
  1114. {$IFDEF DYNAMIC_LINK}
  1115. var
  1116.   _CredReadDomainCredentials: Pointer;
  1117. function CredReadDomainCredentials;
  1118. begin
  1119.   GetProcedureAddress(_CredReadDomainCredentials, credapi, 'CredReadDomainCredentialsW');
  1120.   asm
  1121.     mov esp, ebp
  1122.     pop ebp
  1123.     jmp [_CredReadDomainCredentials]
  1124.   end;
  1125. end;
  1126. {$ELSE}
  1127. function CredReadDomainCredentials; external credapi name 'CredReadDomainCredentialsW';
  1128. {$ENDIF DYNAMIC_LINK}
  1129. {$ELSE}
  1130. {$IFDEF DYNAMIC_LINK}
  1131. var
  1132.   _CredReadDomainCredentials: Pointer;
  1133. function CredReadDomainCredentials;
  1134. begin
  1135.   GetProcedureAddress(_CredReadDomainCredentials, credapi, 'CredReadDomainCredentialsA');
  1136.   asm
  1137.     mov esp, ebp
  1138.     pop ebp
  1139.     jmp [_CredReadDomainCredentials]
  1140.   end;
  1141. end;
  1142. {$ELSE}
  1143. function CredReadDomainCredentials; external credapi name 'CredReadDomainCredentialsA';
  1144. {$ENDIF DYNAMIC_LINK}
  1145. {$ENDIF}
  1146. {$IFDEF DYNAMIC_LINK}
  1147. var
  1148.   _CredDeleteW: Pointer;
  1149. function CredDeleteW;
  1150. begin
  1151.   GetProcedureAddress(_CredDeleteW, credapi, 'CredDeleteW');
  1152.   asm
  1153.     mov esp, ebp
  1154.     pop ebp
  1155.     jmp [_CredDeleteW]
  1156.   end;
  1157. end;
  1158. {$ELSE}
  1159. function CredDeleteW; external credapi name 'CredDeleteW';
  1160. {$ENDIF DYNAMIC_LINK}
  1161. {$IFDEF DYNAMIC_LINK}
  1162. var
  1163.   _CredDeleteA: Pointer;
  1164. function CredDeleteA;
  1165. begin
  1166.   GetProcedureAddress(_CredDeleteA, credapi, 'CredDeleteA');
  1167.   asm
  1168.     mov esp, ebp
  1169.     pop ebp
  1170.     jmp [_CredDeleteA]
  1171.   end;
  1172. end;
  1173. {$ELSE}
  1174. function CredDeleteA; external credapi name 'CredDeleteA';
  1175. {$ENDIF DYNAMIC_LINK}
  1176. {$IFDEF UNICODE}
  1177. {$IFDEF DYNAMIC_LINK}
  1178. var
  1179.   _CredDelete: Pointer;
  1180. function CredDelete;
  1181. begin
  1182.   GetProcedureAddress(_CredDelete, credapi, 'CredDeleteW');
  1183.   asm
  1184.     mov esp, ebp
  1185.     pop ebp
  1186.     jmp [_CredDelete]
  1187.   end;
  1188. end;
  1189. {$ELSE}
  1190. function CredDelete; external credapi name 'CredDeleteW';
  1191. {$ENDIF DYNAMIC_LINK}
  1192. {$ELSE}
  1193. {$IFDEF DYNAMIC_LINK}
  1194. var
  1195.   _CredDelete: Pointer;
  1196. function CredDelete;
  1197. begin
  1198.   GetProcedureAddress(_CredDelete, credapi, 'CredDeleteA');
  1199.   asm
  1200.     mov esp, ebp
  1201.     pop ebp
  1202.     jmp [_CredDelete]
  1203.   end;
  1204. end;
  1205. {$ELSE}
  1206. function CredDelete; external credapi name 'CredDeleteA';
  1207. {$ENDIF DYNAMIC_LINK}
  1208. {$ENDIF}
  1209. {$IFDEF DYNAMIC_LINK}
  1210. var
  1211.   _CredRenameW: Pointer;
  1212. function CredRenameW;
  1213. begin
  1214.   GetProcedureAddress(_CredRenameW, credapi, 'CredRenameW');
  1215.   asm
  1216.     mov esp, ebp
  1217.     pop ebp
  1218.     jmp [_CredRenameW]
  1219.   end;
  1220. end;
  1221. {$ELSE}
  1222. function CredRenameW; external credapi name 'CredRenameW';
  1223. {$ENDIF DYNAMIC_LINK}
  1224. {$IFDEF DYNAMIC_LINK}
  1225. var
  1226.   _CredRenameA: Pointer;
  1227. function CredRenameA;
  1228. begin
  1229.   GetProcedureAddress(_CredRenameA, credapi, 'CredRenameA');
  1230.   asm
  1231.     mov esp, ebp
  1232.     pop ebp
  1233.     jmp [_CredRenameA]
  1234.   end;
  1235. end;
  1236. {$ELSE}
  1237. function CredRenameA; external credapi name 'CredRenameA';
  1238. {$ENDIF DYNAMIC_LINK}
  1239. {$IFDEF UNICODE}
  1240. {$IFDEF DYNAMIC_LINK}
  1241. var
  1242.   _CredRename: Pointer;
  1243. function CredRename;
  1244. begin
  1245.   GetProcedureAddress(_CredRename, credapi, 'CredRenameW');
  1246.   asm
  1247.     mov esp, ebp
  1248.     pop ebp
  1249.     jmp [_CredRename]
  1250.   end;
  1251. end;
  1252. {$ELSE}
  1253. function CredRename; external credapi name 'CredRenameW';
  1254. {$ENDIF DYNAMIC_LINK}
  1255. {$ELSE}
  1256. {$IFDEF DYNAMIC_LINK}
  1257. var
  1258.   _CredRename: Pointer;
  1259. function CredRename;
  1260. begin
  1261.   GetProcedureAddress(_CredRename, credapi, 'CredRenameA');
  1262.   asm
  1263.     mov esp, ebp
  1264.     pop ebp
  1265.     jmp [_CredRename]
  1266.   end;
  1267. end;
  1268. {$ELSE}
  1269. function CredRename; external credapi name 'CredRenameA';
  1270. {$ENDIF DYNAMIC_LINK}
  1271. {$ENDIF}
  1272. {$IFDEF DYNAMIC_LINK}
  1273. var
  1274.   _CredGetTargetInfoW: Pointer;
  1275. function CredGetTargetInfoW;
  1276. begin
  1277.   GetProcedureAddress(_CredGetTargetInfoW, credapi, 'CredGetTargetInfoW');
  1278.   asm
  1279.     mov esp, ebp
  1280.     pop ebp
  1281.     jmp [_CredGetTargetInfoW]
  1282.   end;
  1283. end;
  1284. {$ELSE}
  1285. function CredGetTargetInfoW; external credapi name 'CredGetTargetInfoW';
  1286. {$ENDIF DYNAMIC_LINK}
  1287. {$IFDEF DYNAMIC_LINK}
  1288. var
  1289.   _CredGetTargetInfoA: Pointer;
  1290. function CredGetTargetInfoA;
  1291. begin
  1292.   GetProcedureAddress(_CredGetTargetInfoA, credapi, 'CredGetTargetInfoA');
  1293.   asm
  1294.     mov esp, ebp
  1295.     pop ebp
  1296.     jmp [_CredGetTargetInfoA]
  1297.   end;
  1298. end;
  1299. {$ELSE}
  1300. function CredGetTargetInfoA; external credapi name 'CredGetTargetInfoA';
  1301. {$ENDIF DYNAMIC_LINK}
  1302. {$IFDEF UNICODE}
  1303. {$IFDEF DYNAMIC_LINK}
  1304. var
  1305.   _CredGetTargetInfo: Pointer;
  1306. function CredGetTargetInfo;
  1307. begin
  1308.   GetProcedureAddress(_CredGetTargetInfo, credapi, 'CredGetTargetInfoA');
  1309.   asm
  1310.     mov esp, ebp
  1311.     pop ebp
  1312.     jmp [_CredGetTargetInfo]
  1313.   end;
  1314. end;
  1315. {$ELSE}
  1316. function CredGetTargetInfo; external credapi name 'CredGetTargetInfoA';
  1317. {$ENDIF DYNAMIC_LINK}
  1318. {$ELSE}
  1319. {$IFDEF DYNAMIC_LINK}
  1320. var
  1321.   _CredGetTargetInfo: Pointer;
  1322. function CredGetTargetInfo;
  1323. begin
  1324.   GetProcedureAddress(_CredGetTargetInfo, credapi, 'CredGetTargetInfoA');
  1325.   asm
  1326.     mov esp, ebp
  1327.     pop ebp
  1328.     jmp [_CredGetTargetInfo]
  1329.   end;
  1330. end;
  1331. {$ELSE}
  1332. function CredGetTargetInfo; external credapi name 'CredGetTargetInfoA';
  1333. {$ENDIF DYNAMIC_LINK}
  1334. {$ENDIF}
  1335. {$IFDEF DYNAMIC_LINK}
  1336. var
  1337.   _CredMarshalCredentialW: Pointer;
  1338. function CredMarshalCredentialW;
  1339. begin
  1340.   GetProcedureAddress(_CredMarshalCredentialW, credapi, 'CredMarshalCredentialW');
  1341.   asm
  1342.     mov esp, ebp
  1343.     pop ebp
  1344.     jmp [_CredMarshalCredentialW]
  1345.   end;
  1346. end;
  1347. {$ELSE}
  1348. function CredMarshalCredentialW; external credapi name 'CredMarshalCredentialW';
  1349. {$ENDIF DYNAMIC_LINK}
  1350. {$IFDEF DYNAMIC_LINK}
  1351. var
  1352.   _CredMarshalCredentialA: Pointer;
  1353. function CredMarshalCredentialA;
  1354. begin
  1355.   GetProcedureAddress(_CredMarshalCredentialA, credapi, 'CredMarshalCredentialA');
  1356.   asm
  1357.     mov esp, ebp
  1358.     pop ebp
  1359.     jmp [_CredMarshalCredentialA]
  1360.   end;
  1361. end;
  1362. {$ELSE}
  1363. function CredMarshalCredentialA; external credapi name 'CredMarshalCredentialA';
  1364. {$ENDIF DYNAMIC_LINK}
  1365. {$IFDEF UNICODE}
  1366. {$IFDEF DYNAMIC_LINK}
  1367. var
  1368.   _CredMarshalCredential: Pointer;
  1369. function CredMarshalCredential;
  1370. begin
  1371.   GetProcedureAddress(_CredMarshalCredential, credapi, 'CredMarshalCredentialW');
  1372.   asm
  1373.     mov esp, ebp
  1374.     pop ebp
  1375.     jmp [_CredMarshalCredential]
  1376.   end;
  1377. end;
  1378. {$ELSE}
  1379. function CredMarshalCredential; external credapi name 'CredMarshalCredentialW';
  1380. {$ENDIF DYNAMIC_LINK}
  1381. {$ELSE}
  1382. {$IFDEF DYNAMIC_LINK}
  1383. var
  1384.   _CredMarshalCredential: Pointer;
  1385. function CredMarshalCredential;
  1386. begin
  1387.   GetProcedureAddress(_CredMarshalCredential, credapi, 'CredMarshalCredentialA');
  1388.   asm
  1389.     mov esp, ebp
  1390.     pop ebp
  1391.     jmp [_CredMarshalCredential]
  1392.   end;
  1393. end;
  1394. {$ELSE}
  1395. function CredMarshalCredential; external credapi name 'CredMarshalCredentialA';
  1396. {$ENDIF DYNAMIC_LINK}
  1397. {$ENDIF}
  1398. {$IFDEF DYNAMIC_LINK}
  1399. var
  1400.   _CredUnmarshalCredentialW: Pointer;
  1401. function CredUnmarshalCredentialW;
  1402. begin
  1403.   GetProcedureAddress(_CredUnmarshalCredentialW, credapi, 'CredUnmarshalCredentialW');
  1404.   asm
  1405.     mov esp, ebp
  1406.     pop ebp
  1407.     jmp [_CredUnmarshalCredentialW]
  1408.   end;
  1409. end;
  1410. {$ELSE}
  1411. function CredUnmarshalCredentialW; external credapi name 'CredUnmarshalCredentialW';
  1412. {$ENDIF DYNAMIC_LINK}
  1413. {$IFDEF DYNAMIC_LINK}
  1414. var
  1415.   _CredUnmarshalCredentialA: Pointer;
  1416. function CredUnmarshalCredentialA;
  1417. begin
  1418.   GetProcedureAddress(_CredUnmarshalCredentialA, credapi, 'CredUnmarshalCredentialA');
  1419.   asm
  1420.     mov esp, ebp
  1421.     pop ebp
  1422.     jmp [_CredUnmarshalCredentialA]
  1423.   end;
  1424. end;
  1425. {$ELSE}
  1426. function CredUnmarshalCredentialA; external credapi name 'CredUnmarshalCredentialA';
  1427. {$ENDIF DYNAMIC_LINK}
  1428. {$IFDEF UNICODE}
  1429. {$IFDEF DYNAMIC_LINK}
  1430. var
  1431.   _CredUnmarshalCredential: Pointer;
  1432. function CredUnmarshalCredential;
  1433. begin
  1434.   GetProcedureAddress(_CredUnmarshalCredential, credapi, 'CredUnmarshalCredentialW');
  1435.   asm
  1436.     mov esp, ebp
  1437.     pop ebp
  1438.     jmp [_CredUnmarshalCredential]
  1439.   end;
  1440. end;
  1441. {$ELSE}
  1442. function CredUnmarshalCredential; external credapi name 'CredUnmarshalCredentialW';
  1443. {$ENDIF DYNAMIC_LINK}
  1444. {$ELSE}
  1445. {$IFDEF DYNAMIC_LINK}
  1446. var
  1447.   _CredUnmarshalCredential: Pointer;
  1448. function CredUnmarshalCredential;
  1449. begin
  1450.   GetProcedureAddress(_CredUnmarshalCredential, credapi, 'CredUnmarshalCredentialA');
  1451.   asm
  1452.     mov esp, ebp
  1453.     pop ebp
  1454.     jmp [_CredUnmarshalCredential]
  1455.   end;
  1456. end;
  1457. {$ELSE}
  1458. function CredUnmarshalCredential; external credapi name 'CredUnmarshalCredentialA';
  1459. {$ENDIF DYNAMIC_LINK}
  1460. {$ENDIF}
  1461. {$IFDEF DYNAMIC_LINK}
  1462. var
  1463.   _CredIsMarshaledCredentialW: Pointer;
  1464. function CredIsMarshaledCredentialW;
  1465. begin
  1466.   GetProcedureAddress(_CredIsMarshaledCredentialW, credapi, 'CredIsMarshaledCredentialW');
  1467.   asm
  1468.     mov esp, ebp
  1469.     pop ebp
  1470.     jmp [_CredIsMarshaledCredentialW]
  1471.   end;
  1472. end;
  1473. {$ELSE}
  1474. function CredIsMarshaledCredentialW; external credapi name 'CredIsMarshaledCredentialW';
  1475. {$ENDIF DYNAMIC_LINK}
  1476. {$IFDEF DYNAMIC_LINK}
  1477. var
  1478.   _CredIsMarshaledCredentialA: Pointer;
  1479. function CredIsMarshaledCredentialA;
  1480. begin
  1481.   GetProcedureAddress(_CredIsMarshaledCredentialA, credapi, 'CredIsMarshaledCredentialA');
  1482.   asm
  1483.     mov esp, ebp
  1484.     pop ebp
  1485.     jmp [_CredIsMarshaledCredentialA]
  1486.   end;
  1487. end;
  1488. {$ELSE}
  1489. function CredIsMarshaledCredentialA; external credapi name 'CredIsMarshaledCredentialA';
  1490. {$ENDIF DYNAMIC_LINK}
  1491. {$IFDEF UNICODE}
  1492. {$IFDEF DYNAMIC_LINK}
  1493. var
  1494.   _CredIsMarshaledCredential: Pointer;
  1495. function CredIsMarshaledCredential;
  1496. begin
  1497.   GetProcedureAddress(_CredIsMarshaledCredential, credapi, 'CredIsMarshaledCredentialW');
  1498.   asm
  1499.     mov esp, ebp
  1500.     pop ebp
  1501.     jmp [_CredIsMarshaledCredential]
  1502.   end;
  1503. end;
  1504. {$ELSE}
  1505. function CredIsMarshaledCredential; external credapi name 'CredIsMarshaledCredentialW';
  1506. {$ENDIF DYNAMIC_LINK}
  1507. {$ELSE}
  1508. {$IFDEF DYNAMIC_LINK}
  1509. var
  1510.   _CredIsMarshaledCredential: Pointer;
  1511. function CredIsMarshaledCredential;
  1512. begin
  1513.   GetProcedureAddress(_CredIsMarshaledCredential, credapi, 'CredIsMarshaledCredentialA');
  1514.   asm
  1515.     mov esp, ebp
  1516.     pop ebp
  1517.     jmp [_CredIsMarshaledCredential]
  1518.   end;
  1519. end;
  1520. {$ELSE}
  1521. function CredIsMarshaledCredential; external credapi name 'CredIsMarshaledCredentialA';
  1522. {$ENDIF DYNAMIC_LINK}
  1523. {$ENDIF}
  1524. {$IFDEF DYNAMIC_LINK}
  1525. var
  1526.   _CredGetSessionTypes: Pointer;
  1527. function CredGetSessionTypes;
  1528. begin
  1529.   GetProcedureAddress(_CredGetSessionTypes, credapi, 'CredGetSessionTypes');
  1530.   asm
  1531.     mov esp, ebp
  1532.     pop ebp
  1533.     jmp [_CredGetSessionTypes]
  1534.   end;
  1535. end;
  1536. {$ELSE}
  1537. function CredGetSessionTypes; external credapi name 'CredGetSessionTypes';
  1538. {$ENDIF DYNAMIC_LINK}
  1539. {$IFDEF DYNAMIC_LINK}
  1540. var
  1541.   _CredFree: Pointer;
  1542. procedure CredFree;
  1543. begin
  1544.   GetProcedureAddress(_CredFree, credapi, 'CredFree');
  1545.   asm
  1546.     mov esp, ebp
  1547.     pop ebp
  1548.     jmp [_CredFree]
  1549.   end;
  1550. end;
  1551. {$ELSE}
  1552. procedure CredFree; external credapi name 'CredFree';
  1553. {$ENDIF DYNAMIC_LINK}
  1554. {$IFDEF DYNAMIC_LINK}
  1555. var
  1556.   _CredUIPromptForCredentialsW: Pointer;
  1557. function CredUIPromptForCredentialsW;
  1558. begin
  1559.   GetProcedureAddress(_CredUIPromptForCredentialsW, credui, 'CredUIPromptForCredentialsW');
  1560.   asm
  1561.     mov esp, ebp
  1562.     pop ebp
  1563.     jmp [_CredUIPromptForCredentialsW]
  1564.   end;
  1565. end;
  1566. {$ELSE}
  1567. function CredUIPromptForCredentialsW; external credui name 'CredUIPromptForCredentialsW';
  1568. {$ENDIF DYNAMIC_LINK}
  1569. {$IFDEF DYNAMIC_LINK}
  1570. var
  1571.   _CredUIPromptForCredentialsA: Pointer;
  1572. function CredUIPromptForCredentialsA;
  1573. begin
  1574.   GetProcedureAddress(_CredUIPromptForCredentialsA, credui, 'CredUIPromptForCredentialsA');
  1575.   asm
  1576.     mov esp, ebp
  1577.     pop ebp
  1578.     jmp [_CredUIPromptForCredentialsA]
  1579.   end;
  1580. end;
  1581. {$ELSE}
  1582. function CredUIPromptForCredentialsA; external credui name 'CredUIPromptForCredentialsA';
  1583. {$ENDIF DYNAMIC_LINK}
  1584. {$IFDEF UNICODE}
  1585. {$IFDEF DYNAMIC_LINK}
  1586. var
  1587.   _CredUIPromptForCredentials: Pointer;
  1588. function CredUIPromptForCredentials;
  1589. begin
  1590.   GetProcedureAddress(_CredUIPromptForCredentials, credui, 'CredUIPromptForCredentialsW');
  1591.   asm
  1592.     mov esp, ebp
  1593.     pop ebp
  1594.     jmp [_CredUIPromptForCredentials]
  1595.   end;
  1596. end;
  1597. {$ELSE}
  1598. function CredUIPromptForCredentials; external credui name 'CredUIPromptForCredentialsW';
  1599. {$ENDIF DYNAMIC_LINK}
  1600. {$ELSE}
  1601. {$IFDEF DYNAMIC_LINK}
  1602. var
  1603.   _CredUIPromptForCredentials: Pointer;
  1604. function CredUIPromptForCredentials;
  1605. begin
  1606.   GetProcedureAddress(_CredUIPromptForCredentials, credui, 'CredUIPromptForCredentialsA');
  1607.   asm
  1608.     mov esp, ebp
  1609.     pop ebp
  1610.     jmp [_CredUIPromptForCredentials]
  1611.   end;
  1612. end;
  1613. {$ELSE}
  1614. function CredUIPromptForCredentials; external credui name 'CredUIPromptForCredentialsA';
  1615. {$ENDIF DYNAMIC_LINK}
  1616. {$ENDIF}
  1617. {$IFDEF DYNAMIC_LINK}
  1618. var
  1619.   _CredUIParseUserNameW: Pointer;
  1620. function CredUIParseUserNameW;
  1621. begin
  1622.   GetProcedureAddress(_CredUIParseUserNameW, credui, 'CredUIParseUserNameW');
  1623.   asm
  1624.     mov esp, ebp
  1625.     pop ebp
  1626.     jmp [_CredUIParseUserNameW]
  1627.   end;
  1628. end;
  1629. {$ELSE}
  1630. function CredUIParseUserNameW; external credui name 'CredUIParseUserNameW';
  1631. {$ENDIF DYNAMIC_LINK}
  1632. {$IFDEF DYNAMIC_LINK}
  1633. var
  1634.   _CredUIParseUserNameA: Pointer;
  1635. function CredUIParseUserNameA;
  1636. begin
  1637.   GetProcedureAddress(_CredUIParseUserNameA, credui, 'CredUIParseUserNameA');
  1638.   asm
  1639.     mov esp, ebp
  1640.     pop ebp
  1641.     jmp [_CredUIParseUserNameA]
  1642.   end;
  1643. end;
  1644. {$ELSE}
  1645. function CredUIParseUserNameA; external credui name 'CredUIParseUserNameA';
  1646. {$ENDIF DYNAMIC_LINK}
  1647. {$IFDEF UNICODE}
  1648. {$IFDEF DYNAMIC_LINK}
  1649. var
  1650.   _CredUIParseUserName: Pointer;
  1651. function CredUIParseUserName;
  1652. begin
  1653.   GetProcedureAddress(_CredUIParseUserName, credui, 'CredUIParseUserNameW');
  1654.   asm
  1655.     mov esp, ebp
  1656.     pop ebp
  1657.     jmp [_CredUIParseUserName]
  1658.   end;
  1659. end;
  1660. {$ELSE}
  1661. function CredUIParseUserName; external credui name 'CredUIParseUserNameW';
  1662. {$ENDIF DYNAMIC_LINK}
  1663. {$ELSE}
  1664. {$IFDEF DYNAMIC_LINK}
  1665. var
  1666.   _CredUIParseUserName: Pointer;
  1667. function CredUIParseUserName;
  1668. begin
  1669.   GetProcedureAddress(_CredUIParseUserName, credui, 'CredUIParseUserNameA');
  1670.   asm
  1671.     mov esp, ebp
  1672.     pop ebp
  1673.     jmp [_CredUIParseUserName]
  1674.   end;
  1675. end;
  1676. {$ELSE}
  1677. function CredUIParseUserName; external credui name 'CredUIParseUserNameA';
  1678. {$ENDIF DYNAMIC_LINK}
  1679. {$ENDIF}
  1680. {$IFDEF DYNAMIC_LINK}
  1681. var
  1682.   _CredUICmdLinePromptForCredentialsW: Pointer;
  1683. function CredUICmdLinePromptForCredentialsW;
  1684. begin
  1685.   GetProcedureAddress(_CredUICmdLinePromptForCredentialsW, credui, 'CredUICmdLinePromptForCredentialsW');
  1686.   asm
  1687.     mov esp, ebp
  1688.     pop ebp
  1689.     jmp [_CredUICmdLinePromptForCredentialsW]
  1690.   end;
  1691. end;
  1692. {$ELSE}
  1693. function CredUICmdLinePromptForCredentialsW; external credui name 'CredUICmdLinePromptForCredentialsW';
  1694. {$ENDIF DYNAMIC_LINK}
  1695. {$IFDEF DYNAMIC_LINK}
  1696. var
  1697.   _CredUICmdLinePromptForCredentialsA: Pointer;
  1698. function CredUICmdLinePromptForCredentialsA;
  1699. begin
  1700.   GetProcedureAddress(_CredUICmdLinePromptForCredentialsA, credui, 'CredUICmdLinePromptForCredentialsA');
  1701.   asm
  1702.     mov esp, ebp
  1703.     pop ebp
  1704.     jmp [_CredUICmdLinePromptForCredentialsA]
  1705.   end;
  1706. end;
  1707. {$ELSE}
  1708. function CredUICmdLinePromptForCredentialsA; external credui name 'CredUICmdLinePromptForCredentialsA';
  1709. {$ENDIF DYNAMIC_LINK}
  1710. {$IFDEF UNICODE}
  1711. {$IFDEF DYNAMIC_LINK}
  1712. var
  1713.   _CredUICmdLinePromptForCredentials: Pointer;
  1714. function CredUICmdLinePromptForCredentials;
  1715. begin
  1716.   GetProcedureAddress(_CredUICmdLinePromptForCredentials, credui, 'CredUICmdLinePromptForCredentialsW');
  1717.   asm
  1718.     mov esp, ebp
  1719.     pop ebp
  1720.     jmp [_CredUICmdLinePromptForCredentials]
  1721.   end;
  1722. end;
  1723. {$ELSE}
  1724. function CredUICmdLinePromptForCredentials; external credui name 'CredUICmdLinePromptForCredentialsW';
  1725. {$ENDIF DYNAMIC_LINK}
  1726. {$ELSE}
  1727. {$IFDEF DYNAMIC_LINK}
  1728. var
  1729.   _CredUICmdLinePromptForCredentials: Pointer;
  1730. function CredUICmdLinePromptForCredentials;
  1731. begin
  1732.   GetProcedureAddress(_CredUICmdLinePromptForCredentials, credui, 'CredUICmdLinePromptForCredentialsA');
  1733.   asm
  1734.     mov esp, ebp
  1735.     pop ebp
  1736.     jmp [_CredUICmdLinePromptForCredentials]
  1737.   end;
  1738. end;
  1739. {$ELSE}
  1740. function CredUICmdLinePromptForCredentials; external credui name 'CredUICmdLinePromptForCredentialsA';
  1741. {$ENDIF DYNAMIC_LINK}
  1742. {$ENDIF}
  1743. {$IFDEF DYNAMIC_LINK}
  1744. var
  1745.   _CredUIConfirmCredentialsW: Pointer;
  1746. function CredUIConfirmCredentialsW;
  1747. begin
  1748.   GetProcedureAddress(_CredUIConfirmCredentialsW, credui, 'CredUIConfirmCredentialsW');
  1749.   asm
  1750.     mov esp, ebp
  1751.     pop ebp
  1752.     jmp [_CredUIConfirmCredentialsW]
  1753.   end;
  1754. end;
  1755. {$ELSE}
  1756. function CredUIConfirmCredentialsW; external credui name 'CredUIConfirmCredentialsW';
  1757. {$ENDIF DYNAMIC_LINK}
  1758. {$IFDEF DYNAMIC_LINK}
  1759. var
  1760.   _CredUIConfirmCredentialsA: Pointer;
  1761. function CredUIConfirmCredentialsA;
  1762. begin
  1763.   GetProcedureAddress(_CredUIConfirmCredentialsA, credui, 'CredUIConfirmCredentialsA');
  1764.   asm
  1765.     mov esp, ebp
  1766.     pop ebp
  1767.     jmp [_CredUIConfirmCredentialsA]
  1768.   end;
  1769. end;
  1770. {$ELSE}
  1771. function CredUIConfirmCredentialsA; external credui name 'CredUIConfirmCredentialsA';
  1772. {$ENDIF DYNAMIC_LINK}
  1773. {$IFDEF UNICODE}
  1774. {$IFDEF DYNAMIC_LINK}
  1775. var
  1776.   _CredUIConfirmCredentials: Pointer;
  1777. function CredUIConfirmCredentials;
  1778. begin
  1779.   GetProcedureAddress(_CredUIConfirmCredentials, credui, 'CredUIConfirmCredentialsW');
  1780.   asm
  1781.     mov esp, ebp
  1782.     pop ebp
  1783.     jmp [_CredUIConfirmCredentials]
  1784.   end;
  1785. end;
  1786. {$ELSE}
  1787. function CredUIConfirmCredentials; external credui name 'CredUIConfirmCredentialsW';
  1788. {$ENDIF DYNAMIC_LINK}
  1789. {$ELSE}
  1790. {$IFDEF DYNAMIC_LINK}
  1791. var
  1792.   _CredUIConfirmCredentials: Pointer;
  1793. function CredUIConfirmCredentials;
  1794. begin
  1795.   GetProcedureAddress(_CredUIConfirmCredentials, credui, 'CredUIConfirmCredentialsA');
  1796.   asm
  1797.     mov esp, ebp
  1798.     pop ebp
  1799.     jmp [_CredUIConfirmCredentials]
  1800.   end;
  1801. end;
  1802. {$ELSE}
  1803. function CredUIConfirmCredentials; external credui name 'CredUIConfirmCredentialsA';
  1804. {$ENDIF DYNAMIC_LINK}
  1805. {$ENDIF}
  1806. end.