jwawincred.pas 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569
  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 att chello dott 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 }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaWinCred;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "wincred.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaLmCons, JwaWinBase, JwaWinError, JwaWinType, JwaNtSecApi;
  51. type
  52. PCtxtHandle = PSecHandle;
  53. {$EXTERNALSYM PCtxtHandle}
  54. //-----------------------------------------------------------------------------
  55. // Macros
  56. //-----------------------------------------------------------------------------
  57. //
  58. // Macro to determine whether CredUIPromptForCredentials should be called upon a failed
  59. // authentication attempt.
  60. //
  61. // Implemented as a macro so that the caller can delay load credui.dll only if this
  62. // macro returns TRUE.
  63. //
  64. // Include only status codes that imply the username/password are wrong or that the
  65. // password is expired. In the former case, asking for a another username or password
  66. // is appropriate. In the later case, we put up a different dialog asking the
  67. // user to change the password on the server.
  68. //
  69. // Don't include status codes such as ERROR_ACCOUNT_DISABLED, ERROR_ACCOUNT_RESTRICTION,
  70. // ERROR_ACCOUNT_LOCKED_OUT, ERROR_ACCOUNT_EXPIRED, ERROR_LOGON_TYPE_NOT_GRANTED.
  71. // For those, the user isn't going to have another account so prompting him
  72. // won't help.
  73. //
  74. // STATUS_DOWNGRADE_DETECTED is included to handle the case where a corporate laptop
  75. // is brought to another LAN. A downgrade attack will indeed be detected,
  76. // but we want to popup UI to allow the user to connect to resources in the
  77. // other LAN.
  78. //
  79. // Don't use the CREDUIP_* macros directly. Their definition is private to credui.dll.
  80. //
  81. // Don't require ntstatus.h
  82. const
  83. STATUS_LOGON_FAILURE = NTSTATUS($C000006D); // ntsubauth
  84. {$EXTERNALSYM STATUS_LOGON_FAILURE}
  85. STATUS_WRONG_PASSWORD = NTSTATUS($C000006A); // ntsubauth
  86. {$EXTERNALSYM STATUS_WRONG_PASSWORD}
  87. STATUS_PASSWORD_EXPIRED = NTSTATUS($C0000071); // ntsubauth
  88. {$EXTERNALSYM STATUS_PASSWORD_EXPIRED}
  89. STATUS_PASSWORD_MUST_CHANGE = NTSTATUS($C0000224); // ntsubauth
  90. {$EXTERNALSYM STATUS_PASSWORD_MUST_CHANGE}
  91. STATUS_ACCESS_DENIED = NTSTATUS($C0000022);
  92. {$EXTERNALSYM STATUS_ACCESS_DENIED}
  93. STATUS_DOWNGRADE_DETECTED = NTSTATUS($C0000388);
  94. {$EXTERNALSYM STATUS_DOWNGRADE_DETECTED}
  95. STATUS_AUTHENTICATION_FIREWALL_FAILED = NTSTATUS($C0000413);
  96. {$EXTERNALSYM STATUS_AUTHENTICATION_FIREWALL_FAILED}
  97. STATUS_ACCOUNT_DISABLED = NTSTATUS($C0000072); // ntsubauth
  98. {$EXTERNALSYM STATUS_ACCOUNT_DISABLED}
  99. STATUS_ACCOUNT_RESTRICTION = NTSTATUS($C000006E); // ntsubauth
  100. {$EXTERNALSYM STATUS_ACCOUNT_RESTRICTION}
  101. STATUS_ACCOUNT_LOCKED_OUT = NTSTATUS($C0000234); // ntsubauth
  102. {$EXTERNALSYM STATUS_ACCOUNT_LOCKED_OUT}
  103. STATUS_ACCOUNT_EXPIRED = NTSTATUS($C0000193); // ntsubauth
  104. {$EXTERNALSYM STATUS_ACCOUNT_EXPIRED}
  105. STATUS_LOGON_TYPE_NOT_GRANTED = NTSTATUS($C000015B);
  106. {$EXTERNALSYM STATUS_LOGON_TYPE_NOT_GRANTED}
  107. // Don't require lmerr.h
  108. NERR_BASE = 2100;
  109. {$EXTERNALSYM NERR_BASE}
  110. NERR_PasswordExpired = NERR_BASE + 142; // The password of this user has expired.
  111. {$EXTERNALSYM NERR_PasswordExpired}
  112. function CREDUIP_IS_USER_PASSWORD_ERROR(_Status: NTSTATUS): BOOL;
  113. {$EXTERNALSYM CREDUIP_IS_USER_PASSWORD_ERROR}
  114. function CREDUIP_IS_DOWNGRADE_ERROR(_Status: NTSTATUS): BOOL;
  115. {$EXTERNALSYM CREDUIP_IS_DOWNGRADE_ERROR}
  116. function CREDUIP_IS_EXPIRED_ERROR(_Status: NTSTATUS): BOOL;
  117. {$EXTERNALSYM CREDUIP_IS_EXPIRED_ERROR}
  118. function CREDUI_IS_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  119. {$EXTERNALSYM CREDUI_IS_AUTHENTICATION_ERROR}
  120. function CREDUI_NO_PROMPT_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  121. {$EXTERNALSYM CREDUI_NO_PROMPT_AUTHENTICATION_ERROR}
  122. //-----------------------------------------------------------------------------
  123. // Structures
  124. //-----------------------------------------------------------------------------
  125. //
  126. // Credential Attribute
  127. //
  128. const
  129. // Maximum length of the various credential string fields (in characters)
  130. CRED_MAX_STRING_LENGTH = 256;
  131. {$EXTERNALSYM CRED_MAX_STRING_LENGTH}
  132. // Maximum length of the UserName field. The worst case is <User>@<DnsDomain>
  133. CRED_MAX_USERNAME_LENGTH = 256 + 1 + 256;
  134. {$EXTERNALSYM CRED_MAX_USERNAME_LENGTH}
  135. // Maximum length of the TargetName field for CRED_TYPE_GENERIC (in characters)
  136. CRED_MAX_GENERIC_TARGET_NAME_LENGTH = 32767;
  137. {$EXTERNALSYM CRED_MAX_GENERIC_TARGET_NAME_LENGTH}
  138. // Maximum length of the TargetName field for CRED_TYPE_DOMAIN_* (in characters)
  139. // Largest one is <DfsRoot>\<DfsShare>
  140. CRED_MAX_DOMAIN_TARGET_NAME_LENGTH = 256 + 1 + 80;
  141. {$EXTERNALSYM CRED_MAX_DOMAIN_TARGET_NAME_LENGTH}
  142. // Maximum size of the Credential Attribute Value field (in bytes)
  143. CRED_MAX_VALUE_SIZE = 256;
  144. {$EXTERNALSYM CRED_MAX_VALUE_SIZE}
  145. // Maximum number of attributes per credential
  146. CRED_MAX_ATTRIBUTES = 64;
  147. {$EXTERNALSYM CRED_MAX_ATTRIBUTES}
  148. type
  149. PCREDENTIAL_ATTRIBUTEA = ^CREDENTIAL_ATTRIBUTEA;
  150. {$EXTERNALSYM PCREDENTIAL_ATTRIBUTEA}
  151. _CREDENTIAL_ATTRIBUTEA = record
  152. Keyword: LPSTR;
  153. Flags: DWORD;
  154. ValueSize: DWORD;
  155. Value: LPBYTE;
  156. end;
  157. {$EXTERNALSYM _CREDENTIAL_ATTRIBUTEA}
  158. CREDENTIAL_ATTRIBUTEA = _CREDENTIAL_ATTRIBUTEA;
  159. {$EXTERNALSYM CREDENTIAL_ATTRIBUTEA}
  160. TCredentialAttributeA = CREDENTIAL_ATTRIBUTEA;
  161. PCredentialAttributeA = PCREDENTIAL_ATTRIBUTEA;
  162. PCREDENTIAL_ATTRIBUTEW = ^CREDENTIAL_ATTRIBUTEW;
  163. {$EXTERNALSYM PCREDENTIAL_ATTRIBUTEW}
  164. _CREDENTIAL_ATTRIBUTEW = record
  165. Keyword: LPWSTR;
  166. Flags: DWORD;
  167. ValueSize: DWORD;
  168. Value: LPBYTE;
  169. end;
  170. {$EXTERNALSYM _CREDENTIAL_ATTRIBUTEW}
  171. CREDENTIAL_ATTRIBUTEW = _CREDENTIAL_ATTRIBUTEW;
  172. {$EXTERNALSYM CREDENTIAL_ATTRIBUTEW}
  173. TCredentialAttributeW = CREDENTIAL_ATTRIBUTEW;
  174. PCredentialAttributeW = PCREDENTIAL_ATTRIBUTEW;
  175. {$IFDEF UNICODE}
  176. CREDENTIAL_ATTRIBUTE = CREDENTIAL_ATTRIBUTEW;
  177. {$EXTERNALSYM CREDENTIAL_ATTRIBUTE}
  178. PCREDENTIAL_ATTRIBUTE = PCREDENTIAL_ATTRIBUTEW;
  179. {$EXTERNALSYM PCREDENTIAL_ATTRIBUTE}
  180. TCredentialAttribute = TCredentialAttributeW;
  181. PCredentialAttribute = PCredentialAttributeW;
  182. {$ELSE}
  183. CREDENTIAL_ATTRIBUTE = CREDENTIAL_ATTRIBUTEA;
  184. {$EXTERNALSYM CREDENTIAL_ATTRIBUTE}
  185. PCREDENTIAL_ATTRIBUTE = PCREDENTIAL_ATTRIBUTEA;
  186. {$EXTERNALSYM PCREDENTIAL_ATTRIBUTE}
  187. TCredentialAttribute = TCredentialAttributeA;
  188. PCredentialAttribute = PCredentialAttributeA;
  189. {$ENDIF UNICODE}
  190. //
  191. // Special values of the TargetName field
  192. //
  193. const
  194. CRED_SESSION_WILDCARD_NAME_W = WideString('*Session');
  195. {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME_W}
  196. CRED_SESSION_WILDCARD_NAME_A = '*Session';
  197. {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME_A}
  198. CRED_SESSION_WILDCARD_NAME_LENGTH = SizeOf(CRED_SESSION_WILDCARD_NAME_A) - 1;
  199. {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME_LENGTH}
  200. {$IFDEF UNICODE}
  201. CRED_SESSION_WILDCARD_NAME = CRED_SESSION_WILDCARD_NAME_W;
  202. {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME}
  203. {$ELSE}
  204. CRED_SESSION_WILDCARD_NAME = CRED_SESSION_WILDCARD_NAME_A;
  205. {$EXTERNALSYM CRED_SESSION_WILDCARD_NAME}
  206. {$ENDIF UNICODE}
  207. //
  208. // Values of the Credential Flags field.
  209. //
  210. const
  211. CRED_FLAGS_PASSWORD_FOR_CERT = $0001;
  212. {$EXTERNALSYM CRED_FLAGS_PASSWORD_FOR_CERT}
  213. CRED_FLAGS_PROMPT_NOW = $0002;
  214. {$EXTERNALSYM CRED_FLAGS_PROMPT_NOW}
  215. CRED_FLAGS_USERNAME_TARGET = $0004;
  216. {$EXTERNALSYM CRED_FLAGS_USERNAME_TARGET}
  217. CRED_FLAGS_OWF_CRED_BLOB = $0008;
  218. {$EXTERNALSYM CRED_FLAGS_OWF_CRED_BLOB}
  219. CRED_FLAGS_VALID_FLAGS = $000F; // Mask of all valid flags
  220. {$EXTERNALSYM CRED_FLAGS_VALID_FLAGS}
  221. //
  222. // Values of the Credential Type field.
  223. //
  224. CRED_TYPE_GENERIC = 1;
  225. {$EXTERNALSYM CRED_TYPE_GENERIC}
  226. CRED_TYPE_DOMAIN_PASSWORD = 2;
  227. {$EXTERNALSYM CRED_TYPE_DOMAIN_PASSWORD}
  228. CRED_TYPE_DOMAIN_CERTIFICATE = 3;
  229. {$EXTERNALSYM CRED_TYPE_DOMAIN_CERTIFICATE}
  230. CRED_TYPE_DOMAIN_VISIBLE_PASSWORD = 4;
  231. {$EXTERNALSYM CRED_TYPE_DOMAIN_VISIBLE_PASSWORD}
  232. CRED_TYPE_MAXIMUM = 5; // Maximum supported cred type
  233. {$EXTERNALSYM CRED_TYPE_MAXIMUM}
  234. CRED_TYPE_MAXIMUM_EX = CRED_TYPE_MAXIMUM + 1000; // Allow new applications to run on old OSes
  235. {$EXTERNALSYM CRED_TYPE_MAXIMUM_EX}
  236. //
  237. // Maximum size of the CredBlob field (in bytes)
  238. //
  239. CRED_MAX_CREDENTIAL_BLOB_SIZE = 512;
  240. {$EXTERNALSYM CRED_MAX_CREDENTIAL_BLOB_SIZE}
  241. //
  242. // Values of the Credential Persist field
  243. //
  244. CRED_PERSIST_NONE = 0;
  245. {$EXTERNALSYM CRED_PERSIST_NONE}
  246. CRED_PERSIST_SESSION = 1;
  247. {$EXTERNALSYM CRED_PERSIST_SESSION}
  248. CRED_PERSIST_LOCAL_MACHINE = 2;
  249. {$EXTERNALSYM CRED_PERSIST_LOCAL_MACHINE}
  250. CRED_PERSIST_ENTERPRISE = 3;
  251. {$EXTERNALSYM CRED_PERSIST_ENTERPRISE}
  252. //
  253. // A credential
  254. //
  255. type
  256. PCREDENTIALA = ^CREDENTIALA;
  257. {$EXTERNALSYM PCREDENTIALA}
  258. _CREDENTIALA = record
  259. Flags: DWORD;
  260. Type_: DWORD;
  261. TargetName: LPSTR;
  262. Comment: LPSTR;
  263. LastWritten: FILETIME;
  264. CredentialBlobSize: DWORD;
  265. CredentialBlob: LPBYTE;
  266. Persist: DWORD;
  267. AttributeCount: DWORD;
  268. Attributes: PCREDENTIAL_ATTRIBUTEA;
  269. TargetAlias: LPSTR;
  270. UserName: LPSTR;
  271. end;
  272. {$EXTERNALSYM _CREDENTIALA}
  273. CREDENTIALA = _CREDENTIALA;
  274. {$EXTERNALSYM CREDENTIALA}
  275. TCredentialA = CREDENTIALA;
  276. PCREDENTIALW = ^CREDENTIALW;
  277. {$EXTERNALSYM PCREDENTIALW}
  278. _CREDENTIALW = record
  279. Flags: DWORD;
  280. Type_: DWORD;
  281. TargetName: LPWSTR;
  282. Comment: LPWSTR;
  283. LastWritten: FILETIME;
  284. CredentialBlobSize: DWORD;
  285. CredentialBlob: LPBYTE;
  286. Persist: DWORD;
  287. AttributeCount: DWORD;
  288. Attributes: PCREDENTIAL_ATTRIBUTEW;
  289. TargetAlias: LPWSTR;
  290. UserName: LPWSTR;
  291. end;
  292. {$EXTERNALSYM _CREDENTIALW}
  293. CREDENTIALW = _CREDENTIALW;
  294. {$EXTERNALSYM CREDENTIALW}
  295. TCredentialW = CREDENTIALW;
  296. {$IFDEF UNICODE}
  297. CREDENTIAL = CREDENTIALW;
  298. {$EXTERNALSYM CREDENTIAL}
  299. PCREDENTIAL = PCREDENTIALW;
  300. {$EXTERNALSYM PCREDENTIAL}
  301. TCredential = TCredentialW;
  302. {$ELSE}
  303. CREDENTIAL = CREDENTIALA;
  304. {$EXTERNALSYM CREDENTIAL}
  305. PCREDENTIAL = PCREDENTIALA;
  306. {$EXTERNALSYM PCREDENTIAL}
  307. TCredential = TCredentialA;
  308. {$ENDIF UNICODE}
  309. //
  310. // Value of the Flags field in CREDENTIAL_TARGET_INFORMATION
  311. //
  312. const
  313. CRED_TI_SERVER_FORMAT_UNKNOWN = $0001; // Don't know if server name is DNS or netbios format
  314. {$EXTERNALSYM CRED_TI_SERVER_FORMAT_UNKNOWN}
  315. CRED_TI_DOMAIN_FORMAT_UNKNOWN = $0002; // Don't know if domain name is DNS or netbios format
  316. {$EXTERNALSYM CRED_TI_DOMAIN_FORMAT_UNKNOWN}
  317. CRED_TI_ONLY_PASSWORD_REQUIRED = $0004; // Server only requires a password and not a username
  318. {$EXTERNALSYM CRED_TI_ONLY_PASSWORD_REQUIRED}
  319. CRED_TI_USERNAME_TARGET = $0008; // TargetName is username
  320. {$EXTERNALSYM CRED_TI_USERNAME_TARGET}
  321. CRED_TI_CREATE_EXPLICIT_CRED = $0010; // When creating a cred, create one named TargetInfo->TargetName
  322. {$EXTERNALSYM CRED_TI_CREATE_EXPLICIT_CRED}
  323. CRED_TI_WORKGROUP_MEMBER = $0020; // Indicates the machine is a member of a workgroup
  324. {$EXTERNALSYM CRED_TI_WORKGROUP_MEMBER}
  325. CRED_TI_VALID_FLAGS = $003F;
  326. {$EXTERNALSYM CRED_TI_VALID_FLAGS}
  327. //
  328. // A credential target
  329. //
  330. type
  331. PCREDENTIAL_TARGET_INFORMATIONA = ^CREDENTIAL_TARGET_INFORMATIONA;
  332. {$EXTERNALSYM PCREDENTIAL_TARGET_INFORMATIONA}
  333. _CREDENTIAL_TARGET_INFORMATIONA = record
  334. TargetName: LPSTR;
  335. NetbiosServerName: LPSTR;
  336. DnsServerName: LPSTR;
  337. NetbiosDomainName: LPSTR;
  338. DnsDomainName: LPSTR;
  339. DnsTreeName: LPSTR;
  340. PackageName: LPSTR;
  341. Flags: ULONG;
  342. CredTypeCount: DWORD;
  343. CredTypes: LPDWORD;
  344. end;
  345. {$EXTERNALSYM _CREDENTIAL_TARGET_INFORMATIONA}
  346. CREDENTIAL_TARGET_INFORMATIONA = _CREDENTIAL_TARGET_INFORMATIONA;
  347. {$EXTERNALSYM CREDENTIAL_TARGET_INFORMATIONA}
  348. TCredentialTargetInformationA = CREDENTIAL_TARGET_INFORMATIONA;
  349. PCredentialTargetInformationA = PCREDENTIAL_TARGET_INFORMATIONA;
  350. PCREDENTIAL_TARGET_INFORMATIONW = ^CREDENTIAL_TARGET_INFORMATIONW;
  351. {$EXTERNALSYM PCREDENTIAL_TARGET_INFORMATIONW}
  352. _CREDENTIAL_TARGET_INFORMATIONW = record
  353. TargetName: LPWSTR;
  354. NetbiosServerName: LPWSTR;
  355. DnsServerName: LPWSTR;
  356. NetbiosDomainName: LPWSTR;
  357. DnsDomainName: LPWSTR;
  358. DnsTreeName: LPWSTR;
  359. PackageName: LPWSTR;
  360. Flags: ULONG;
  361. CredTypeCount: DWORD;
  362. CredTypes: LPDWORD;
  363. end;
  364. {$EXTERNALSYM _CREDENTIAL_TARGET_INFORMATIONW}
  365. CREDENTIAL_TARGET_INFORMATIONW = _CREDENTIAL_TARGET_INFORMATIONW;
  366. {$EXTERNALSYM CREDENTIAL_TARGET_INFORMATIONW}
  367. TCredentialTargetInformationW = CREDENTIAL_TARGET_INFORMATIONW;
  368. PCredentialTargetInformationW = PCREDENTIAL_TARGET_INFORMATIONW;
  369. {$IFDEF UNICODE}
  370. CREDENTIAL_TARGET_INFORMATION = CREDENTIAL_TARGET_INFORMATIONW;
  371. {$EXTERNALSYM CREDENTIAL_TARGET_INFORMATION}
  372. PCREDENTIAL_TARGET_INFORMATION = PCREDENTIAL_TARGET_INFORMATIONW;
  373. {$EXTERNALSYM PCREDENTIAL_TARGET_INFORMATION}
  374. TCredentialTargetInformation = TCredentialTargetInformationW;
  375. PCredentialTargetInformation = PCredentialTargetInformationW;
  376. {$ELSE}
  377. CREDENTIAL_TARGET_INFORMATION = CREDENTIAL_TARGET_INFORMATIONA;
  378. {$EXTERNALSYM CREDENTIAL_TARGET_INFORMATION}
  379. PCREDENTIAL_TARGET_INFORMATION = PCREDENTIAL_TARGET_INFORMATIONA;
  380. {$EXTERNALSYM PCREDENTIAL_TARGET_INFORMATION}
  381. TCredentialTargetInformation = TCredentialTargetInformationA;
  382. PCredentialTargetInformation = PCredentialTargetInformationA;
  383. {$ENDIF UNICODE}
  384. //
  385. // Certificate credential information
  386. //
  387. // The cbSize should be the size of the structure, sizeof(CERT_CREDENTIAL_INFO),
  388. // rgbHashofCert is the hash of the cert which is to be used as the credential.
  389. //
  390. const
  391. CERT_HASH_LENGTH = 20; // SHA1 hashes are used for cert hashes
  392. {$EXTERNALSYM CERT_HASH_LENGTH}
  393. type
  394. PCERT_CREDENTIAL_INFO = ^CERT_CREDENTIAL_INFO;
  395. {$EXTERNALSYM PCERT_CREDENTIAL_INFO}
  396. _CERT_CREDENTIAL_INFO = record
  397. cbSize: ULONG;
  398. rgbHashOfCert: array [0..CERT_HASH_LENGTH - 1] of UCHAR;
  399. end;
  400. {$EXTERNALSYM _CERT_CREDENTIAL_INFO}
  401. CERT_CREDENTIAL_INFO = _CERT_CREDENTIAL_INFO;
  402. {$EXTERNALSYM CERT_CREDENTIAL_INFO}
  403. TCertCredentialInfo = CERT_CREDENTIAL_INFO;
  404. PCertCredentialInfo = PCERT_CREDENTIAL_INFO;
  405. //
  406. // Username Target credential information
  407. //
  408. // This credential can be pass to LsaLogonUser to ask it to find a credential with a
  409. // TargetName of UserName.
  410. //
  411. PUSERNAME_TARGET_CREDENTIAL_INFO = ^USERNAME_TARGET_CREDENTIAL_INFO;
  412. {$EXTERNALSYM PUSERNAME_TARGET_CREDENTIAL_INFO}
  413. _USERNAME_TARGET_CREDENTIAL_INFO = record
  414. UserName: LPWSTR;
  415. end;
  416. {$EXTERNALSYM _USERNAME_TARGET_CREDENTIAL_INFO}
  417. USERNAME_TARGET_CREDENTIAL_INFO = _USERNAME_TARGET_CREDENTIAL_INFO;
  418. {$EXTERNALSYM USERNAME_TARGET_CREDENTIAL_INFO}
  419. TUsernameTargetCredentialInfo = USERNAME_TARGET_CREDENTIAL_INFO;
  420. PUsernameTargetCredentialInfo = PUSERNAME_TARGET_CREDENTIAL_INFO;
  421. //
  422. // Credential type for credential marshaling routines
  423. //
  424. _CRED_MARSHAL_TYPE = DWORD;
  425. {$EXTERNALSYM _CRED_MARSHAL_TYPE}
  426. CRED_MARSHAL_TYPE = _CRED_MARSHAL_TYPE;
  427. {$EXTERNALSYM CRED_MARSHAL_TYPE}
  428. PCRED_MARSHAL_TYPE = ^CRED_MARSHAL_TYPE;
  429. {$EXTERNALSYM PCRED_MARSHAL_TYPE}
  430. TCredMarshalType = CRED_MARSHAL_TYPE;
  431. PCredMarshalType = PCRED_MARSHAL_TYPE;
  432. const
  433. CertCredential = 1;
  434. {$EXTERNALSYM CertCredential}
  435. UsernameTargetCredential = 2;
  436. {$EXTERNALSYM UsernameTargetCredential}
  437. //
  438. // Credential UI info
  439. //
  440. type
  441. PCREDUI_INFOA = ^CREDUI_INFOA;
  442. {$EXTERNALSYM PCREDUI_INFOA}
  443. _CREDUI_INFOA = record
  444. cbSize: DWORD;
  445. hwndParent: HWND;
  446. pszMessageText: PCSTR;
  447. pszCaptionText: PCSTR;
  448. hbmBanner: HBITMAP;
  449. end;
  450. {$EXTERNALSYM _CREDUI_INFOA}
  451. CREDUI_INFOA = _CREDUI_INFOA;
  452. {$EXTERNALSYM CREDUI_INFOA}
  453. TCredUIInfoA = CREDUI_INFOA;
  454. PCredUIInfoA = PCREDUI_INFOA;
  455. PCREDUI_INFOW = ^CREDUI_INFOW;
  456. {$EXTERNALSYM PCREDUI_INFOW}
  457. _CREDUI_INFOW = record
  458. cbSize: DWORD;
  459. hwndParent: HWND;
  460. pszMessageText: LPCWSTR;
  461. pszCaptionText: LPCWSTR;
  462. hbmBanner: HBITMAP;
  463. end;
  464. {$EXTERNALSYM _CREDUI_INFOW}
  465. CREDUI_INFOW = _CREDUI_INFOW;
  466. {$EXTERNALSYM CREDUI_INFOW}
  467. TCredUIInfoW = CREDUI_INFOW;
  468. PCredUIInfoW = PCREDUI_INFOW;
  469. {$IFDEF UNICODE}
  470. CREDUI_INFO = CREDUI_INFOW;
  471. {$EXTERNALSYM CREDUI_INFO}
  472. PCREDUI_INFO = PCREDUI_INFOW;
  473. {$EXTERNALSYM PCREDUI_INFO}
  474. TCredUIInfo = TCredUIInfoW;
  475. PCredUIInfo = PCredUIInfoW;
  476. {$ELSE}
  477. CREDUI_INFO = CREDUI_INFOA;
  478. {$EXTERNALSYM CREDUI_INFO}
  479. PCREDUI_INFO = PCREDUI_INFOA;
  480. {$EXTERNALSYM PCREDUI_INFO}
  481. TCredUIInfo = TCredUIInfoA;
  482. PCredUIInfo = PCredUIInfoA;
  483. {$ENDIF UNICODE}
  484. //-----------------------------------------------------------------------------
  485. // Values
  486. //-----------------------------------------------------------------------------
  487. // String length limits:
  488. const
  489. CREDUI_MAX_MESSAGE_LENGTH = 32767;
  490. {$EXTERNALSYM CREDUI_MAX_MESSAGE_LENGTH}
  491. CREDUI_MAX_CAPTION_LENGTH = 128;
  492. {$EXTERNALSYM CREDUI_MAX_CAPTION_LENGTH}
  493. CREDUI_MAX_GENERIC_TARGET_LENGTH = CRED_MAX_GENERIC_TARGET_NAME_LENGTH;
  494. {$EXTERNALSYM CREDUI_MAX_GENERIC_TARGET_LENGTH}
  495. CREDUI_MAX_DOMAIN_TARGET_LENGTH = CRED_MAX_DOMAIN_TARGET_NAME_LENGTH;
  496. {$EXTERNALSYM CREDUI_MAX_DOMAIN_TARGET_LENGTH}
  497. CREDUI_MAX_USERNAME_LENGTH = CRED_MAX_USERNAME_LENGTH;
  498. {$EXTERNALSYM CREDUI_MAX_USERNAME_LENGTH}
  499. CREDUI_MAX_PASSWORD_LENGTH = CRED_MAX_CREDENTIAL_BLOB_SIZE div 2;
  500. {$EXTERNALSYM CREDUI_MAX_PASSWORD_LENGTH}
  501. //
  502. // Flags for CredUIPromptForCredentials and/or CredUICmdLinePromptForCredentials
  503. //
  504. CREDUI_FLAGS_INCORRECT_PASSWORD = $00001; // indicates the username is valid, but password is not
  505. {$EXTERNALSYM CREDUI_FLAGS_INCORRECT_PASSWORD}
  506. CREDUI_FLAGS_DO_NOT_PERSIST = $00002; // Do not show "Save" checkbox, and do not persist credentials
  507. {$EXTERNALSYM CREDUI_FLAGS_DO_NOT_PERSIST}
  508. CREDUI_FLAGS_REQUEST_ADMINISTRATOR = $00004; // Populate list box with admin accounts
  509. {$EXTERNALSYM CREDUI_FLAGS_REQUEST_ADMINISTRATOR}
  510. CREDUI_FLAGS_EXCLUDE_CERTIFICATES = $00008; // do not include certificates in the drop list
  511. {$EXTERNALSYM CREDUI_FLAGS_EXCLUDE_CERTIFICATES}
  512. CREDUI_FLAGS_REQUIRE_CERTIFICATE = $00010;
  513. {$EXTERNALSYM CREDUI_FLAGS_REQUIRE_CERTIFICATE}
  514. CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX = $00040;
  515. {$EXTERNALSYM CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX}
  516. CREDUI_FLAGS_ALWAYS_SHOW_UI = $00080;
  517. {$EXTERNALSYM CREDUI_FLAGS_ALWAYS_SHOW_UI}
  518. CREDUI_FLAGS_REQUIRE_SMARTCARD = $00100;
  519. {$EXTERNALSYM CREDUI_FLAGS_REQUIRE_SMARTCARD}
  520. CREDUI_FLAGS_PASSWORD_ONLY_OK = $00200;
  521. {$EXTERNALSYM CREDUI_FLAGS_PASSWORD_ONLY_OK}
  522. CREDUI_FLAGS_VALIDATE_USERNAME = $00400;
  523. {$EXTERNALSYM CREDUI_FLAGS_VALIDATE_USERNAME}
  524. CREDUI_FLAGS_COMPLETE_USERNAME = $00800;
  525. {$EXTERNALSYM CREDUI_FLAGS_COMPLETE_USERNAME}
  526. CREDUI_FLAGS_PERSIST = $01000; // Do not show "Save" checkbox, but persist credentials anyway
  527. {$EXTERNALSYM CREDUI_FLAGS_PERSIST}
  528. CREDUI_FLAGS_SERVER_CREDENTIAL = $04000;
  529. {$EXTERNALSYM CREDUI_FLAGS_SERVER_CREDENTIAL}
  530. CREDUI_FLAGS_EXPECT_CONFIRMATION = $20000; // do not persist unless caller later confirms credential via CredUIConfirmCredential() api
  531. {$EXTERNALSYM CREDUI_FLAGS_EXPECT_CONFIRMATION}
  532. CREDUI_FLAGS_GENERIC_CREDENTIALS = $40000; // Credential is a generic credential
  533. {$EXTERNALSYM CREDUI_FLAGS_GENERIC_CREDENTIALS}
  534. CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS = $80000; // Credential has a username as the target
  535. {$EXTERNALSYM CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS}
  536. CREDUI_FLAGS_KEEP_USERNAME = $100000; // don't allow the user to change the supplied username
  537. {$EXTERNALSYM CREDUI_FLAGS_KEEP_USERNAME}
  538. //
  539. // Mask of flags valid for CredUIPromptForCredentials
  540. //
  541. CREDUI_FLAGS_PROMPT_VALID =
  542. CREDUI_FLAGS_INCORRECT_PASSWORD or
  543. CREDUI_FLAGS_DO_NOT_PERSIST or
  544. CREDUI_FLAGS_REQUEST_ADMINISTRATOR or
  545. CREDUI_FLAGS_EXCLUDE_CERTIFICATES or
  546. CREDUI_FLAGS_REQUIRE_CERTIFICATE or
  547. CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX or
  548. CREDUI_FLAGS_ALWAYS_SHOW_UI or
  549. CREDUI_FLAGS_REQUIRE_SMARTCARD or
  550. CREDUI_FLAGS_PASSWORD_ONLY_OK or
  551. CREDUI_FLAGS_VALIDATE_USERNAME or
  552. CREDUI_FLAGS_COMPLETE_USERNAME or
  553. CREDUI_FLAGS_PERSIST or
  554. CREDUI_FLAGS_SERVER_CREDENTIAL or
  555. CREDUI_FLAGS_EXPECT_CONFIRMATION or
  556. CREDUI_FLAGS_GENERIC_CREDENTIALS or
  557. CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS or
  558. CREDUI_FLAGS_KEEP_USERNAME;
  559. {$EXTERNALSYM CREDUI_FLAGS_PROMPT_VALID}
  560. //-----------------------------------------------------------------------------
  561. // Functions
  562. //-----------------------------------------------------------------------------
  563. //
  564. // Values of flags to CredWrite and CredWriteDomainCredentials
  565. //
  566. const
  567. CRED_PRESERVE_CREDENTIAL_BLOB = $1;
  568. {$EXTERNALSYM CRED_PRESERVE_CREDENTIAL_BLOB}
  569. function CredWriteA(Credential: PCREDENTIALA; Flags: DWORD): BOOL; stdcall;
  570. {$EXTERNALSYM CredWriteA}
  571. function CredWriteW(Credential: PCREDENTIALW; Flags: DWORD): BOOL; stdcall;
  572. {$EXTERNALSYM CredWriteW}
  573. function CredWrite(Credential: PCREDENTIAL; Flags: DWORD): BOOL; stdcall;
  574. {$EXTERNALSYM CredWrite}
  575. function CredReadA(TargetName: LPCSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  576. {$EXTERNALSYM CredReadA}
  577. function CredReadW(TargetName: LPCWSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  578. {$EXTERNALSYM CredReadW}
  579. function CredRead(TargetName: LPCTSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIAL): BOOL; stdcall;
  580. {$EXTERNALSYM CredRead}
  581. function CredEnumerateA(Filter: LPCSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  582. {$EXTERNALSYM CredEnumerateA}
  583. function CredEnumerateW(Filter: LPCWSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  584. {$EXTERNALSYM CredEnumerateW}
  585. function CredEnumerate(Filter: LPCTSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIAL): BOOL; stdcall;
  586. {$EXTERNALSYM CredEnumerate}
  587. function CredWriteDomainCredentialsA(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA; Credential: PCREDENTIALA; Flags: DWORD): BOOL; stdcall;
  588. {$EXTERNALSYM CredWriteDomainCredentialsA}
  589. function CredWriteDomainCredentialsW(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW; Credential: PCREDENTIALW; Flags: DWORD): BOOL; stdcall;
  590. {$EXTERNALSYM CredWriteDomainCredentialsW}
  591. function CredWriteDomainCredentials(TargetInfo: PCREDENTIAL_TARGET_INFORMATION; Credential: PCREDENTIAL; Flags: DWORD): BOOL; stdcall;
  592. {$EXTERNALSYM CredWriteDomainCredentials}
  593. //
  594. // Values of flags to CredReadDomainCredentials
  595. //
  596. const
  597. CRED_CACHE_TARGET_INFORMATION = $1;
  598. {$EXTERNALSYM CRED_CACHE_TARGET_INFORMATION}
  599. function CredReadDomainCredentialsA(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  600. {$EXTERNALSYM CredReadDomainCredentialsA}
  601. function CredReadDomainCredentialsW(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  602. {$EXTERNALSYM CredReadDomainCredentialsW}
  603. function CredReadDomainCredentials(TargetInfo: PCREDENTIAL_TARGET_INFORMATION; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIAL): BOOL; stdcall;
  604. {$EXTERNALSYM CredReadDomainCredentials}
  605. function CredDeleteA(TargetName: LPCSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  606. {$EXTERNALSYM CredDeleteA}
  607. function CredDeleteW(TargetName: LPCWSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  608. {$EXTERNALSYM CredDeleteW}
  609. function CredDelete(TargetName: LPCTSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  610. {$EXTERNALSYM CredDelete}
  611. function CredRenameA(OldTargetName: LPCSTR; NewTargetName: LPCSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  612. {$EXTERNALSYM CredRenameA}
  613. function CredRenameW(OldTargetName: LPCWSTR; NewTargetName: LPCWSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  614. {$EXTERNALSYM CredRenameW}
  615. function CredRename(OldTargetName: LPCTSTR; NewTargetName: LPCTSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  616. {$EXTERNALSYM CredRename}
  617. //
  618. // Values of flags to CredGetTargetInfo
  619. //
  620. const
  621. CRED_ALLOW_NAME_RESOLUTION = $1;
  622. {$EXTERNALSYM CRED_ALLOW_NAME_RESOLUTION}
  623. function CredGetTargetInfoA(TargetName: LPCSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA): BOOL; stdcall;
  624. {$EXTERNALSYM CredGetTargetInfoA}
  625. function CredGetTargetInfoW(TargetName: LPCWSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW): BOOL; stdcall;
  626. {$EXTERNALSYM CredGetTargetInfoW}
  627. function CredGetTargetInfo(TargetName: LPCTSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATION): BOOL; stdcall;
  628. {$EXTERNALSYM CredGetTargetInfo}
  629. function CredMarshalCredentialA(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; MarshaledCredential: LPSTR): BOOL; stdcall;
  630. {$EXTERNALSYM CredMarshalCredentialA}
  631. function CredMarshalCredentialW(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; var MarshaledCredential: LPWSTR): BOOL; stdcall;
  632. {$EXTERNALSYM CredMarshalCredentialW}
  633. function CredMarshalCredential(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; var MarshaledCredential: LPTSTR): BOOL; stdcall;
  634. {$EXTERNALSYM CredMarshalCredential}
  635. function CredUnmarshalCredentialA(MarshaledCredential: LPCSTR; CredType: PCRED_MARSHAL_TYPE; Credential: PVOID): BOOL; stdcall;
  636. {$EXTERNALSYM CredUnmarshalCredentialA}
  637. function CredUnmarshalCredentialW(MarshaledCredential: LPCWSTR; CredType: PCRED_MARSHAL_TYPE; var Credential: PVOID): BOOL; stdcall;
  638. {$EXTERNALSYM CredUnmarshalCredentialW}
  639. function CredUnmarshalCredential(MarshaledCredential: LPCTSTR; CredType: PCRED_MARSHAL_TYPE; var Credential: PVOID): BOOL; stdcall;
  640. {$EXTERNALSYM CredUnmarshalCredential}
  641. function CredIsMarshaledCredentialA(MarshaledCredential: LPCSTR): BOOL; stdcall;
  642. {$EXTERNALSYM CredIsMarshaledCredentialA}
  643. function CredIsMarshaledCredentialW(MarshaledCredential: LPCWSTR): BOOL; stdcall;
  644. {$EXTERNALSYM CredIsMarshaledCredentialW}
  645. function CredIsMarshaledCredential(MarshaledCredential: LPCTSTR): BOOL; stdcall;
  646. {$EXTERNALSYM CredIsMarshaledCredential}
  647. function CredGetSessionTypes(MaximumPersistCount: DWORD; MaximumPersist: LPDWORD): BOOL; stdcall;
  648. {$EXTERNALSYM CredGetSessionTypes}
  649. procedure CredFree(Buffer: PVOID); stdcall;
  650. {$EXTERNALSYM CredFree}
  651. 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;
  652. {$EXTERNALSYM CredUIPromptForCredentialsA}
  653. 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;
  654. {$EXTERNALSYM CredUIPromptForCredentialsW}
  655. function CredUIPromptForCredentials(pUiInfo: PCREDUI_INFO; pszTargetName: LPCTSTR; pContext: PCtxtHandle; dwAuthError: DWORD; pszUserName: PTSTR; ulUserNameBufferSize: ULONG; pszPassword: PTSTR; ulPasswordBufferSize: ULONG; var save: BOOL; dwFlags: DWORD): DWORD; stdcall;
  656. {$EXTERNALSYM CredUIPromptForCredentials}
  657. function CredUIParseUserNameA(pszUserName: PCSTR; pszUser: PSTR; ulUserBufferSize: ULONG; pszDomain: PSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  658. {$EXTERNALSYM CredUIParseUserNameA}
  659. function CredUIParseUserNameW(pszUserName: LPCWSTR; pszUser: PWSTR; ulUserBufferSize: ULONG; pszDomain: PWSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  660. {$EXTERNALSYM CredUIParseUserNameW}
  661. function CredUIParseUserName(pszUserName: LPCTSTR; pszUser: PTSTR; ulUserBufferSize: ULONG; pszDomain: PTSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  662. {$EXTERNALSYM CredUIParseUserName}
  663. function CredUICmdLinePromptForCredentialsA(pszTargetName: PCSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PSTR; ulUserBufferSize: ULONG; pszPassword: PSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  664. {$EXTERNALSYM CredUICmdLinePromptForCredentialsA}
  665. function CredUICmdLinePromptForCredentialsW(pszTargetName: LPCWSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PWSTR; ulUserBufferSize: ULONG; pszPassword: PWSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  666. {$EXTERNALSYM CredUICmdLinePromptForCredentialsW}
  667. function CredUICmdLinePromptForCredentials(pszTargetName: LPCTSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PTSTR; ulUserBufferSize: ULONG; pszPassword: PTSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  668. {$EXTERNALSYM CredUICmdLinePromptForCredentials}
  669. //
  670. // Call this API with bConfirm set to TRUE to confirm that the credential (previously created
  671. // via CredUIGetCredentials or CredUIPromptForCredentials worked, or with bConfirm set to FALSE
  672. // to indicate it didn't
  673. function CredUIConfirmCredentialsA(pszTargetName: PCSTR; bConfirm: BOOL): DWORD; stdcall;
  674. {$EXTERNALSYM CredUIConfirmCredentialsA}
  675. function CredUIConfirmCredentialsW(pszTargetName: LPCWSTR; bConfirm: BOOL): DWORD; stdcall;
  676. {$EXTERNALSYM CredUIConfirmCredentialsW}
  677. function CredUIConfirmCredentials(pszTargetName: LPCTSTR; bConfirm: BOOL): DWORD; stdcall;
  678. {$EXTERNALSYM CredUIConfirmCredentials}
  679. function CredUIStoreSSOCredW(pszRealm, pszUsername, pszPassword: LPCWSTR; bPersist: BOOL): DWORD; stdcall;
  680. {$EXTERNALSYM CredUIStoreSSOCredW}
  681. function CredUIReadSSOCredW(pszRealm: LPCWSTR; out ppszUsername: PWSTR): DWORD; stdcall;
  682. {$EXTERNALSYM CredUIReadSSOCredW}
  683. implementation
  684. const
  685. credapi = 'advapi32.dll';
  686. credui = 'credui.dll';
  687. {$IFDEF UNICODE}
  688. AWSuffix = 'W';
  689. {$ELSE}
  690. AWSuffix = 'A';
  691. {$ENDIF UNICODE}
  692. function CREDUIP_IS_USER_PASSWORD_ERROR(_Status: NTSTATUS): BOOL;
  693. begin
  694. Result :=
  695. (DWORD(_Status) = ERROR_LOGON_FAILURE) or
  696. (_Status = HRESULT_FROM_WIN32(ERROR_LOGON_FAILURE)) or
  697. (_Status = STATUS_LOGON_FAILURE) or
  698. (_Status = HRESULT_FROM_NT(STATUS_LOGON_FAILURE)) or
  699. (DWORD(_Status) = ERROR_ACCESS_DENIED) or
  700. (_Status = HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED)) or
  701. (_Status = STATUS_ACCESS_DENIED) or
  702. (_Status = HRESULT_FROM_NT(STATUS_ACCESS_DENIED)) or
  703. (DWORD(_Status) = ERROR_INVALID_PASSWORD) or
  704. (_Status = HRESULT_FROM_WIN32(ERROR_INVALID_PASSWORD)) or
  705. (_Status = STATUS_WRONG_PASSWORD) or
  706. (_Status = HRESULT_FROM_NT(STATUS_WRONG_PASSWORD)) or
  707. (_Status = SEC_E_NO_CREDENTIALS) or
  708. (_Status = SEC_E_LOGON_DENIED);
  709. end;
  710. function CREDUIP_IS_DOWNGRADE_ERROR(_Status: NTSTATUS): BOOL;
  711. begin
  712. Result :=
  713. (DWORD(_Status) = ERROR_DOWNGRADE_DETECTED) or
  714. (_Status = HRESULT_FROM_WIN32(ERROR_DOWNGRADE_DETECTED)) or
  715. (_Status = STATUS_DOWNGRADE_DETECTED) or
  716. (_Status = HRESULT_FROM_NT(STATUS_DOWNGRADE_DETECTED))
  717. end;
  718. function CREDUIP_IS_EXPIRED_ERROR(_Status: NTSTATUS): BOOL;
  719. begin
  720. Result :=
  721. (DWORD(_Status) = ERROR_PASSWORD_EXPIRED) or
  722. (_Status = HRESULT_FROM_WIN32( ERROR_PASSWORD_EXPIRED)) or
  723. (_Status = STATUS_PASSWORD_EXPIRED) or
  724. (_Status = HRESULT_FROM_NT( STATUS_PASSWORD_EXPIRED)) or
  725. (DWORD(_Status) = ERROR_PASSWORD_MUST_CHANGE) or
  726. (_Status = HRESULT_FROM_WIN32( ERROR_PASSWORD_MUST_CHANGE)) or
  727. (_Status = STATUS_PASSWORD_MUST_CHANGE) or
  728. (_Status = HRESULT_FROM_NT( STATUS_PASSWORD_MUST_CHANGE)) or
  729. (_Status = NERR_PasswordExpired) or
  730. (_Status = HRESULT_FROM_WIN32(NERR_PasswordExpired));
  731. end;
  732. function CREDUI_IS_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  733. begin
  734. Result := CREDUIP_IS_USER_PASSWORD_ERROR(_Status) or CREDUIP_IS_DOWNGRADE_ERROR(_Status) or CREDUIP_IS_EXPIRED_ERROR(_Status);
  735. end;
  736. function CREDUI_NO_PROMPT_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  737. begin
  738. Result :=
  739. (_Status = NTSTATUS(ERROR_AUTHENTICATION_FIREWALL_FAILED)) or
  740. (_Status = HRESULT_FROM_WIN32(ERROR_AUTHENTICATION_FIREWALL_FAILED)) or
  741. (_Status = STATUS_AUTHENTICATION_FIREWALL_FAILED) or
  742. (_Status = HRESULT_FROM_NT(STATUS_AUTHENTICATION_FIREWALL_FAILED)) or
  743. (DWORD(_Status) = ERROR_ACCOUNT_DISABLED) or
  744. (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_DISABLED)) or
  745. (_Status = STATUS_ACCOUNT_DISABLED) or
  746. (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_DISABLED)) or
  747. (DWORD(_Status) = ERROR_ACCOUNT_RESTRICTION) or
  748. (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_RESTRICTION)) or
  749. (_Status = STATUS_ACCOUNT_RESTRICTION) or
  750. (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_RESTRICTION)) or
  751. (DWORD(_Status) = ERROR_ACCOUNT_LOCKED_OUT) or
  752. (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_LOCKED_OUT)) or
  753. (_Status = STATUS_ACCOUNT_LOCKED_OUT) or
  754. (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_LOCKED_OUT)) or
  755. (DWORD(_Status) = ERROR_ACCOUNT_EXPIRED) or
  756. (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_EXPIRED)) or
  757. (_Status = STATUS_ACCOUNT_EXPIRED) or
  758. (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_EXPIRED)) or
  759. (DWORD(_Status) = ERROR_LOGON_TYPE_NOT_GRANTED) or
  760. (_Status = HRESULT_FROM_WIN32(ERROR_LOGON_TYPE_NOT_GRANTED)) or
  761. (_Status = STATUS_LOGON_TYPE_NOT_GRANTED) or
  762. (_Status = HRESULT_FROM_NT(STATUS_LOGON_TYPE_NOT_GRANTED));
  763. end;
  764. {$IFDEF DYNAMIC_LINK}
  765. var
  766. _CredWriteW: Pointer;
  767. function CredWriteW;
  768. begin
  769. GetProcedureAddress(_CredWriteW, credapi, 'CredWriteW');
  770. asm
  771. MOV ESP, EBP
  772. POP EBP
  773. JMP [_CredWriteW]
  774. end;
  775. end;
  776. var
  777. _CredWriteA: Pointer;
  778. function CredWriteA;
  779. begin
  780. GetProcedureAddress(_CredWriteA, credapi, 'CredWriteA');
  781. asm
  782. MOV ESP, EBP
  783. POP EBP
  784. JMP [_CredWriteA]
  785. end;
  786. end;
  787. var
  788. _CredWrite: Pointer;
  789. function CredWrite;
  790. begin
  791. GetProcedureAddress(_CredWrite, credapi, 'CredWrite' + AWSuffix);
  792. asm
  793. MOV ESP, EBP
  794. POP EBP
  795. JMP [_CredWrite]
  796. end;
  797. end;
  798. var
  799. _CredReadW: Pointer;
  800. function CredReadW;
  801. begin
  802. GetProcedureAddress(_CredReadW, credapi, 'CredReadW');
  803. asm
  804. MOV ESP, EBP
  805. POP EBP
  806. JMP [_CredReadW]
  807. end;
  808. end;
  809. var
  810. _CredReadA: Pointer;
  811. function CredReadA;
  812. begin
  813. GetProcedureAddress(_CredReadA, credapi, 'CredReadA');
  814. asm
  815. MOV ESP, EBP
  816. POP EBP
  817. JMP [_CredReadA]
  818. end;
  819. end;
  820. var
  821. _CredRead: Pointer;
  822. function CredRead;
  823. begin
  824. GetProcedureAddress(_CredRead, credapi, 'CredRead' + AWSuffix);
  825. asm
  826. MOV ESP, EBP
  827. POP EBP
  828. JMP [_CredRead]
  829. end;
  830. end;
  831. var
  832. _CredEnumerateW: Pointer;
  833. function CredEnumerateW;
  834. begin
  835. GetProcedureAddress(_CredEnumerateW, credapi, 'CredEnumerateW');
  836. asm
  837. MOV ESP, EBP
  838. POP EBP
  839. JMP [_CredEnumerateW]
  840. end;
  841. end;
  842. var
  843. _CredEnumerateA: Pointer;
  844. function CredEnumerateA;
  845. begin
  846. GetProcedureAddress(_CredEnumerateA, credapi, 'CredEnumerateA');
  847. asm
  848. MOV ESP, EBP
  849. POP EBP
  850. JMP [_CredEnumerateA]
  851. end;
  852. end;
  853. var
  854. _CredEnumerate: Pointer;
  855. function CredEnumerate;
  856. begin
  857. GetProcedureAddress(_CredEnumerate, credapi, 'CredEnumerate' + AWSuffix);
  858. asm
  859. MOV ESP, EBP
  860. POP EBP
  861. JMP [_CredEnumerate]
  862. end;
  863. end;
  864. var
  865. _CredWriteDomainCredentialsW: Pointer;
  866. function CredWriteDomainCredentialsW;
  867. begin
  868. GetProcedureAddress(_CredWriteDomainCredentialsW, credapi, 'CredWriteDomainCredentialsW');
  869. asm
  870. MOV ESP, EBP
  871. POP EBP
  872. JMP [_CredWriteDomainCredentialsW]
  873. end;
  874. end;
  875. var
  876. _CredWriteDomainCredentialsA: Pointer;
  877. function CredWriteDomainCredentialsA;
  878. begin
  879. GetProcedureAddress(_CredWriteDomainCredentialsA, credapi, 'CredWriteDomainCredentialsA');
  880. asm
  881. MOV ESP, EBP
  882. POP EBP
  883. JMP [_CredWriteDomainCredentialsA]
  884. end;
  885. end;
  886. var
  887. _CredWriteDomainCredentials: Pointer;
  888. function CredWriteDomainCredentials;
  889. begin
  890. GetProcedureAddress(_CredWriteDomainCredentials, credapi, 'CredWriteDomainCredentials' + AWSuffix);
  891. asm
  892. MOV ESP, EBP
  893. POP EBP
  894. JMP [_CredWriteDomainCredentials]
  895. end;
  896. end;
  897. var
  898. _CredReadDomainCredentialsW: Pointer;
  899. function CredReadDomainCredentialsW;
  900. begin
  901. GetProcedureAddress(_CredReadDomainCredentialsW, credapi, 'CredReadDomainCredentialsW');
  902. asm
  903. MOV ESP, EBP
  904. POP EBP
  905. JMP [_CredReadDomainCredentialsW]
  906. end;
  907. end;
  908. var
  909. _CredReadDomainCredentialsA: Pointer;
  910. function CredReadDomainCredentialsA;
  911. begin
  912. GetProcedureAddress(_CredReadDomainCredentialsA, credapi, 'CredReadDomainCredentialsA');
  913. asm
  914. MOV ESP, EBP
  915. POP EBP
  916. JMP [_CredReadDomainCredentialsA]
  917. end;
  918. end;
  919. var
  920. _CredReadDomainCredentials: Pointer;
  921. function CredReadDomainCredentials;
  922. begin
  923. GetProcedureAddress(_CredReadDomainCredentials, credapi, 'CredReadDomainCredentials' + AWSuffix);
  924. asm
  925. MOV ESP, EBP
  926. POP EBP
  927. JMP [_CredReadDomainCredentials]
  928. end;
  929. end;
  930. var
  931. _CredDeleteW: Pointer;
  932. function CredDeleteW;
  933. begin
  934. GetProcedureAddress(_CredDeleteW, credapi, 'CredDeleteW');
  935. asm
  936. MOV ESP, EBP
  937. POP EBP
  938. JMP [_CredDeleteW]
  939. end;
  940. end;
  941. var
  942. _CredDeleteA: Pointer;
  943. function CredDeleteA;
  944. begin
  945. GetProcedureAddress(_CredDeleteA, credapi, 'CredDeleteA');
  946. asm
  947. MOV ESP, EBP
  948. POP EBP
  949. JMP [_CredDeleteA]
  950. end;
  951. end;
  952. var
  953. _CredDelete: Pointer;
  954. function CredDelete;
  955. begin
  956. GetProcedureAddress(_CredDelete, credapi, 'CredDelete' + AWSuffix);
  957. asm
  958. MOV ESP, EBP
  959. POP EBP
  960. JMP [_CredDelete]
  961. end;
  962. end;
  963. var
  964. _CredRenameW: Pointer;
  965. function CredRenameW;
  966. begin
  967. GetProcedureAddress(_CredRenameW, credapi, 'CredRenameW');
  968. asm
  969. MOV ESP, EBP
  970. POP EBP
  971. JMP [_CredRenameW]
  972. end;
  973. end;
  974. var
  975. _CredRenameA: Pointer;
  976. function CredRenameA;
  977. begin
  978. GetProcedureAddress(_CredRenameA, credapi, 'CredRenameA');
  979. asm
  980. MOV ESP, EBP
  981. POP EBP
  982. JMP [_CredRenameA]
  983. end;
  984. end;
  985. var
  986. _CredRename: Pointer;
  987. function CredRename;
  988. begin
  989. GetProcedureAddress(_CredRename, credapi, 'CredRename' + AWSuffix);
  990. asm
  991. MOV ESP, EBP
  992. POP EBP
  993. JMP [_CredRename]
  994. end;
  995. end;
  996. var
  997. _CredGetTargetInfoW: Pointer;
  998. function CredGetTargetInfoW;
  999. begin
  1000. GetProcedureAddress(_CredGetTargetInfoW, credapi, 'CredGetTargetInfoW');
  1001. asm
  1002. MOV ESP, EBP
  1003. POP EBP
  1004. JMP [_CredGetTargetInfoW]
  1005. end;
  1006. end;
  1007. var
  1008. _CredGetTargetInfoA: Pointer;
  1009. function CredGetTargetInfoA;
  1010. begin
  1011. GetProcedureAddress(_CredGetTargetInfoA, credapi, 'CredGetTargetInfoA');
  1012. asm
  1013. MOV ESP, EBP
  1014. POP EBP
  1015. JMP [_CredGetTargetInfoA]
  1016. end;
  1017. end;
  1018. var
  1019. _CredGetTargetInfo: Pointer;
  1020. function CredGetTargetInfo;
  1021. begin
  1022. GetProcedureAddress(_CredGetTargetInfo, credapi, 'CredGetTargetInfoA');
  1023. asm
  1024. MOV ESP, EBP
  1025. POP EBP
  1026. JMP [_CredGetTargetInfo]
  1027. end;
  1028. end;
  1029. var
  1030. _CredMarshalCredentialW: Pointer;
  1031. function CredMarshalCredentialW;
  1032. begin
  1033. GetProcedureAddress(_CredMarshalCredentialW, credapi, 'CredMarshalCredentialW');
  1034. asm
  1035. MOV ESP, EBP
  1036. POP EBP
  1037. JMP [_CredMarshalCredentialW]
  1038. end;
  1039. end;
  1040. var
  1041. _CredMarshalCredentialA: Pointer;
  1042. function CredMarshalCredentialA;
  1043. begin
  1044. GetProcedureAddress(_CredMarshalCredentialA, credapi, 'CredMarshalCredentialA');
  1045. asm
  1046. MOV ESP, EBP
  1047. POP EBP
  1048. JMP [_CredMarshalCredentialA]
  1049. end;
  1050. end;
  1051. var
  1052. _CredMarshalCredential: Pointer;
  1053. function CredMarshalCredential;
  1054. begin
  1055. GetProcedureAddress(_CredMarshalCredential, credapi, 'CredMarshalCredential' + AWSuffix);
  1056. asm
  1057. MOV ESP, EBP
  1058. POP EBP
  1059. JMP [_CredMarshalCredential]
  1060. end;
  1061. end;
  1062. var
  1063. _CredUnmarshalCredentialW: Pointer;
  1064. function CredUnmarshalCredentialW;
  1065. begin
  1066. GetProcedureAddress(_CredUnmarshalCredentialW, credapi, 'CredUnmarshalCredentialW');
  1067. asm
  1068. MOV ESP, EBP
  1069. POP EBP
  1070. JMP [_CredUnmarshalCredentialW]
  1071. end;
  1072. end;
  1073. var
  1074. _CredUnmarshalCredentialA: Pointer;
  1075. function CredUnmarshalCredentialA;
  1076. begin
  1077. GetProcedureAddress(_CredUnmarshalCredentialA, credapi, 'CredUnmarshalCredentialA');
  1078. asm
  1079. MOV ESP, EBP
  1080. POP EBP
  1081. JMP [_CredUnmarshalCredentialA]
  1082. end;
  1083. end;
  1084. var
  1085. _CredUnmarshalCredential: Pointer;
  1086. function CredUnmarshalCredential;
  1087. begin
  1088. GetProcedureAddress(_CredUnmarshalCredential, credapi, 'CredUnmarshalCredential' + AWSuffix);
  1089. asm
  1090. MOV ESP, EBP
  1091. POP EBP
  1092. JMP [_CredUnmarshalCredential]
  1093. end;
  1094. end;
  1095. var
  1096. _CredIsMarshaledCredentialW: Pointer;
  1097. function CredIsMarshaledCredentialW;
  1098. begin
  1099. GetProcedureAddress(_CredIsMarshaledCredentialW, credapi, 'CredIsMarshaledCredentialW');
  1100. asm
  1101. MOV ESP, EBP
  1102. POP EBP
  1103. JMP [_CredIsMarshaledCredentialW]
  1104. end;
  1105. end;
  1106. var
  1107. _CredIsMarshaledCredentialA: Pointer;
  1108. function CredIsMarshaledCredentialA;
  1109. begin
  1110. GetProcedureAddress(_CredIsMarshaledCredentialA, credapi, 'CredIsMarshaledCredentialA');
  1111. asm
  1112. MOV ESP, EBP
  1113. POP EBP
  1114. JMP [_CredIsMarshaledCredentialA]
  1115. end;
  1116. end;
  1117. var
  1118. _CredIsMarshaledCredential: Pointer;
  1119. function CredIsMarshaledCredential;
  1120. begin
  1121. GetProcedureAddress(_CredIsMarshaledCredential, credapi, 'CredIsMarshaledCredential' + AWSuffix);
  1122. asm
  1123. MOV ESP, EBP
  1124. POP EBP
  1125. JMP [_CredIsMarshaledCredential]
  1126. end;
  1127. end;
  1128. var
  1129. _CredGetSessionTypes: Pointer;
  1130. function CredGetSessionTypes;
  1131. begin
  1132. GetProcedureAddress(_CredGetSessionTypes, credapi, 'CredGetSessionTypes');
  1133. asm
  1134. MOV ESP, EBP
  1135. POP EBP
  1136. JMP [_CredGetSessionTypes]
  1137. end;
  1138. end;
  1139. var
  1140. _CredFree: Pointer;
  1141. procedure CredFree;
  1142. begin
  1143. GetProcedureAddress(_CredFree, credapi, 'CredFree');
  1144. asm
  1145. MOV ESP, EBP
  1146. POP EBP
  1147. JMP [_CredFree]
  1148. end;
  1149. end;
  1150. var
  1151. _CredUIPromptForCredentialsW: Pointer;
  1152. function CredUIPromptForCredentialsW;
  1153. begin
  1154. GetProcedureAddress(_CredUIPromptForCredentialsW, credui, 'CredUIPromptForCredentialsW');
  1155. asm
  1156. MOV ESP, EBP
  1157. POP EBP
  1158. JMP [_CredUIPromptForCredentialsW]
  1159. end;
  1160. end;
  1161. var
  1162. _CredUIPromptForCredentialsA: Pointer;
  1163. function CredUIPromptForCredentialsA;
  1164. begin
  1165. GetProcedureAddress(_CredUIPromptForCredentialsA, credui, 'CredUIPromptForCredentialsA');
  1166. asm
  1167. MOV ESP, EBP
  1168. POP EBP
  1169. JMP [_CredUIPromptForCredentialsA]
  1170. end;
  1171. end;
  1172. var
  1173. _CredUIPromptForCredentials: Pointer;
  1174. function CredUIPromptForCredentials;
  1175. begin
  1176. GetProcedureAddress(_CredUIPromptForCredentials, credui, 'CredUIPromptForCredentials' + AWSuffix);
  1177. asm
  1178. MOV ESP, EBP
  1179. POP EBP
  1180. JMP [_CredUIPromptForCredentials]
  1181. end;
  1182. end;
  1183. var
  1184. _CredUIParseUserNameW: Pointer;
  1185. function CredUIParseUserNameW;
  1186. begin
  1187. GetProcedureAddress(_CredUIParseUserNameW, credui, 'CredUIParseUserNameW');
  1188. asm
  1189. MOV ESP, EBP
  1190. POP EBP
  1191. JMP [_CredUIParseUserNameW]
  1192. end;
  1193. end;
  1194. var
  1195. _CredUIParseUserNameA: Pointer;
  1196. function CredUIParseUserNameA;
  1197. begin
  1198. GetProcedureAddress(_CredUIParseUserNameA, credui, 'CredUIParseUserNameA');
  1199. asm
  1200. MOV ESP, EBP
  1201. POP EBP
  1202. JMP [_CredUIParseUserNameA]
  1203. end;
  1204. end;
  1205. var
  1206. _CredUIParseUserName: Pointer;
  1207. function CredUIParseUserName;
  1208. begin
  1209. GetProcedureAddress(_CredUIParseUserName, credui, 'CredUIParseUserName' + AWSuffix);
  1210. asm
  1211. MOV ESP, EBP
  1212. POP EBP
  1213. JMP [_CredUIParseUserName]
  1214. end;
  1215. end;
  1216. var
  1217. _CredUICmdLinePromptForCredentialsW: Pointer;
  1218. function CredUICmdLinePromptForCredentialsW;
  1219. begin
  1220. GetProcedureAddress(_CredUICmdLinePromptForCredentialsW, credui, 'CredUICmdLinePromptForCredentialsW');
  1221. asm
  1222. MOV ESP, EBP
  1223. POP EBP
  1224. JMP [_CredUICmdLinePromptForCredentialsW]
  1225. end;
  1226. end;
  1227. var
  1228. _CredUICmdLinePromptForCredentialsA: Pointer;
  1229. function CredUICmdLinePromptForCredentialsA;
  1230. begin
  1231. GetProcedureAddress(_CredUICmdLinePromptForCredentialsA, credui, 'CredUICmdLinePromptForCredentialsA');
  1232. asm
  1233. MOV ESP, EBP
  1234. POP EBP
  1235. JMP [_CredUICmdLinePromptForCredentialsA]
  1236. end;
  1237. end;
  1238. var
  1239. _CredUICmdLinePromptForCredentials: Pointer;
  1240. function CredUICmdLinePromptForCredentials;
  1241. begin
  1242. GetProcedureAddress(_CredUICmdLinePromptForCredentials, credui, 'CredUICmdLinePromptForCredentials' + AWSuffix);
  1243. asm
  1244. MOV ESP, EBP
  1245. POP EBP
  1246. JMP [_CredUICmdLinePromptForCredentials]
  1247. end;
  1248. end;
  1249. var
  1250. _CredUIConfirmCredentialsW: Pointer;
  1251. function CredUIConfirmCredentialsW;
  1252. begin
  1253. GetProcedureAddress(_CredUIConfirmCredentialsW, credui, 'CredUIConfirmCredentialsW');
  1254. asm
  1255. MOV ESP, EBP
  1256. POP EBP
  1257. JMP [_CredUIConfirmCredentialsW]
  1258. end;
  1259. end;
  1260. var
  1261. _CredUIConfirmCredentialsA: Pointer;
  1262. function CredUIConfirmCredentialsA;
  1263. begin
  1264. GetProcedureAddress(_CredUIConfirmCredentialsA, credui, 'CredUIConfirmCredentialsA');
  1265. asm
  1266. MOV ESP, EBP
  1267. POP EBP
  1268. JMP [_CredUIConfirmCredentialsA]
  1269. end;
  1270. end;
  1271. var
  1272. _CredUIConfirmCredentials: Pointer;
  1273. function CredUIConfirmCredentials;
  1274. begin
  1275. GetProcedureAddress(_CredUIConfirmCredentials, credui, 'CredUIConfirmCredentials' + AWSuffix);
  1276. asm
  1277. MOV ESP, EBP
  1278. POP EBP
  1279. JMP [_CredUIConfirmCredentials]
  1280. end;
  1281. end;
  1282. var
  1283. _CredUIStoreSSOCredW: Pointer;
  1284. function CredUIStoreSSOCredW;
  1285. begin
  1286. GetProcedureAddress(_CredUIStoreSSOCredW, credui, 'CredUIStoreSSOCredW');
  1287. asm
  1288. MOV ESP, EBP
  1289. POP EBP
  1290. JMP [_CredUIStoreSSOCredW]
  1291. end;
  1292. end;
  1293. var
  1294. _CredUIReadSSOCredW: Pointer;
  1295. function CredUIReadSSOCredW;
  1296. begin
  1297. GetProcedureAddress(_CredUIReadSSOCredW, credui, 'CredUIReadSSOCredW');
  1298. asm
  1299. MOV ESP, EBP
  1300. POP EBP
  1301. JMP [_CredUIReadSSOCredW]
  1302. end;
  1303. end;
  1304. {$ELSE}
  1305. function CredWriteW; external credapi name 'CredWriteW';
  1306. function CredWriteA; external credapi name 'CredWriteA';
  1307. function CredWrite; external credapi name 'CredWrite' + AWSuffix;
  1308. function CredReadW; external credapi name 'CredReadW';
  1309. function CredReadA; external credapi name 'CredReadA';
  1310. function CredRead; external credapi name 'CredRead' + AWSuffix;
  1311. function CredEnumerateW; external credapi name 'CredEnumerateW';
  1312. function CredEnumerateA; external credapi name 'CredEnumerateA';
  1313. function CredEnumerate; external credapi name 'CredEnumerate' + AWSuffix;
  1314. function CredWriteDomainCredentialsW; external credapi name 'CredWriteDomainCredentialsW';
  1315. function CredWriteDomainCredentialsA; external credapi name 'CredWriteDomainCredentialsA';
  1316. function CredWriteDomainCredentials; external credapi name 'CredWriteDomainCredentials' + AWSuffix;
  1317. function CredReadDomainCredentialsW; external credapi name 'CredReadDomainCredentialsW';
  1318. function CredReadDomainCredentialsA; external credapi name 'CredReadDomainCredentialsA';
  1319. function CredReadDomainCredentials; external credapi name 'CredReadDomainCredentials' + AWSuffix;
  1320. function CredDeleteW; external credapi name 'CredDeleteW';
  1321. function CredDeleteA; external credapi name 'CredDeleteA';
  1322. function CredDelete; external credapi name 'CredDelete' + AWSuffix;
  1323. function CredRenameW; external credapi name 'CredRenameW';
  1324. function CredRenameA; external credapi name 'CredRenameA';
  1325. function CredRename; external credapi name 'CredRename' + AWSuffix;
  1326. function CredGetTargetInfoW; external credapi name 'CredGetTargetInfoW';
  1327. function CredGetTargetInfoA; external credapi name 'CredGetTargetInfoA';
  1328. function CredGetTargetInfo; external credapi name 'CredGetTargetInfoA';
  1329. function CredMarshalCredentialW; external credapi name 'CredMarshalCredentialW';
  1330. function CredMarshalCredentialA; external credapi name 'CredMarshalCredentialA';
  1331. function CredMarshalCredential; external credapi name 'CredMarshalCredential' + AWSuffix;
  1332. function CredUnmarshalCredentialW; external credapi name 'CredUnmarshalCredentialW';
  1333. function CredUnmarshalCredentialA; external credapi name 'CredUnmarshalCredentialA';
  1334. function CredUnmarshalCredential; external credapi name 'CredUnmarshalCredential' + AWSuffix;
  1335. function CredIsMarshaledCredentialW; external credapi name 'CredIsMarshaledCredentialW';
  1336. function CredIsMarshaledCredentialA; external credapi name 'CredIsMarshaledCredentialA';
  1337. function CredIsMarshaledCredential; external credapi name 'CredIsMarshaledCredential' + AWSuffix;
  1338. function CredGetSessionTypes; external credapi name 'CredGetSessionTypes';
  1339. procedure CredFree; external credapi name 'CredFree';
  1340. function CredUIPromptForCredentialsW; external credui name 'CredUIPromptForCredentialsW';
  1341. function CredUIPromptForCredentialsA; external credui name 'CredUIPromptForCredentialsA';
  1342. function CredUIPromptForCredentials; external credui name 'CredUIPromptForCredentials' + AWSuffix;
  1343. function CredUIParseUserNameW; external credui name 'CredUIParseUserNameW';
  1344. function CredUIParseUserNameA; external credui name 'CredUIParseUserNameA';
  1345. function CredUIParseUserName; external credui name 'CredUIParseUserName' + AWSuffix;
  1346. function CredUICmdLinePromptForCredentialsW; external credui name 'CredUICmdLinePromptForCredentialsW';
  1347. function CredUICmdLinePromptForCredentialsA; external credui name 'CredUICmdLinePromptForCredentialsA';
  1348. function CredUICmdLinePromptForCredentials; external credui name 'CredUICmdLinePromptForCredentials' + AWSuffix;
  1349. function CredUIConfirmCredentialsW; external credui name 'CredUIConfirmCredentialsW';
  1350. function CredUIConfirmCredentialsA; external credui name 'CredUIConfirmCredentialsA';
  1351. function CredUIConfirmCredentials; external credui name 'CredUIConfirmCredentials' + AWSuffix;
  1352. function CredUIStoreSSOCredW; external credui name 'CredUIStoreSSOCredW';
  1353. function CredUIReadSSOCredW; external credui name 'CredUIReadSSOCredW';
  1354. {$ENDIF DYNAMIC_LINK}
  1355. end.