jwawincred.pas 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564
  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. // $Id: JwaWinCred.pas,v 1.12 2005/09/06 16:36:50 marquardt Exp $
  43. unit JwaWinCred;
  44. {$WEAKPACKAGEUNIT}
  45. {$I jediapilib.inc}
  46. interface
  47. uses
  48. JwaLmCons, JwaWindows, JwaNtSecApi;
  49. {$HPPEMIT ''}
  50. {$HPPEMIT '#include "wincred.h"'}
  51. {$HPPEMIT ''}
  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 UNICODE}
  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 UNICODE}
  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 UNICODE}
  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 UNICODE}
  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 UNICODE}
  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 CredWriteA(Credential: PCREDENTIALA; Flags: DWORD): BOOL; stdcall;
  571. {$EXTERNALSYM CredWriteA}
  572. function CredWriteW(Credential: PCREDENTIALW; Flags: DWORD): BOOL; stdcall;
  573. {$EXTERNALSYM CredWriteW}
  574. function CredWrite(Credential: PCREDENTIAL; Flags: DWORD): BOOL; stdcall;
  575. {$EXTERNALSYM CredWrite}
  576. function CredReadA(TargetName: LPCSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  577. {$EXTERNALSYM CredReadA}
  578. function CredReadW(TargetName: LPCWSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  579. {$EXTERNALSYM CredReadW}
  580. function CredRead(TargetName: LPCTSTR; Type_: DWORD; Flags: DWORD; var Credential: PCREDENTIAL): BOOL; stdcall;
  581. {$EXTERNALSYM CredRead}
  582. function CredEnumerateA(Filter: LPCSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  583. {$EXTERNALSYM CredEnumerateA}
  584. function CredEnumerateW(Filter: LPCWSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  585. {$EXTERNALSYM CredEnumerateW}
  586. function CredEnumerate(Filter: LPCTSTR; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIAL): BOOL; stdcall;
  587. {$EXTERNALSYM CredEnumerate}
  588. function CredWriteDomainCredentialsA(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA; Credential: PCREDENTIALA; Flags: DWORD): BOOL; stdcall;
  589. {$EXTERNALSYM CredWriteDomainCredentialsA}
  590. function CredWriteDomainCredentialsW(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW; Credential: PCREDENTIALW; Flags: DWORD): BOOL; stdcall;
  591. {$EXTERNALSYM CredWriteDomainCredentialsW}
  592. function CredWriteDomainCredentials(TargetInfo: PCREDENTIAL_TARGET_INFORMATION; Credential: PCREDENTIAL; Flags: DWORD): BOOL; stdcall;
  593. {$EXTERNALSYM CredWriteDomainCredentials}
  594. //
  595. // Values of flags to CredReadDomainCredentials
  596. //
  597. const
  598. CRED_CACHE_TARGET_INFORMATION = $1;
  599. {$EXTERNALSYM CRED_CACHE_TARGET_INFORMATION}
  600. function CredReadDomainCredentialsA(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALA): BOOL; stdcall;
  601. {$EXTERNALSYM CredReadDomainCredentialsA}
  602. function CredReadDomainCredentialsW(TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIALW): BOOL; stdcall;
  603. {$EXTERNALSYM CredReadDomainCredentialsW}
  604. function CredReadDomainCredentials(TargetInfo: PCREDENTIAL_TARGET_INFORMATION; Flags: DWORD; var Count: DWORD; var Credential: PCREDENTIAL): BOOL; stdcall;
  605. {$EXTERNALSYM CredReadDomainCredentials}
  606. function CredDeleteA(TargetName: LPCSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  607. {$EXTERNALSYM CredDeleteA}
  608. function CredDeleteW(TargetName: LPCWSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  609. {$EXTERNALSYM CredDeleteW}
  610. function CredDelete(TargetName: LPCTSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  611. {$EXTERNALSYM CredDelete}
  612. function CredRenameA(OldTargetName: LPCSTR; NewTargetName: LPCSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  613. {$EXTERNALSYM CredRenameA}
  614. function CredRenameW(OldTargetName: LPCWSTR; NewTargetName: LPCWSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  615. {$EXTERNALSYM CredRenameW}
  616. function CredRename(OldTargetName: LPCTSTR; NewTargetName: LPCTSTR; Type_: DWORD; Flags: DWORD): BOOL; stdcall;
  617. {$EXTERNALSYM CredRename}
  618. //
  619. // Values of flags to CredGetTargetInfo
  620. //
  621. const
  622. CRED_ALLOW_NAME_RESOLUTION = $1;
  623. {$EXTERNALSYM CRED_ALLOW_NAME_RESOLUTION}
  624. function CredGetTargetInfoA(TargetName: LPCSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATIONA): BOOL; stdcall;
  625. {$EXTERNALSYM CredGetTargetInfoA}
  626. function CredGetTargetInfoW(TargetName: LPCWSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATIONW): BOOL; stdcall;
  627. {$EXTERNALSYM CredGetTargetInfoW}
  628. function CredGetTargetInfo(TargetName: LPCTSTR; Flags: DWORD; var TargetInfo: PCREDENTIAL_TARGET_INFORMATION): BOOL; stdcall;
  629. {$EXTERNALSYM CredGetTargetInfo}
  630. function CredMarshalCredentialA(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; MarshaledCredential: LPSTR): BOOL; stdcall;
  631. {$EXTERNALSYM CredMarshalCredentialA}
  632. function CredMarshalCredentialW(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; var MarshaledCredential: LPWSTR): BOOL; stdcall;
  633. {$EXTERNALSYM CredMarshalCredentialW}
  634. function CredMarshalCredential(CredType: CRED_MARSHAL_TYPE; Credential: PVOID; var MarshaledCredential: LPTSTR): BOOL; stdcall;
  635. {$EXTERNALSYM CredMarshalCredential}
  636. function CredUnmarshalCredentialA(MarshaledCredential: LPCSTR; CredType: PCRED_MARSHAL_TYPE; Credential: PVOID): BOOL; stdcall;
  637. {$EXTERNALSYM CredUnmarshalCredentialA}
  638. function CredUnmarshalCredentialW(MarshaledCredential: LPCWSTR; CredType: PCRED_MARSHAL_TYPE; var Credential: PVOID): BOOL; stdcall;
  639. {$EXTERNALSYM CredUnmarshalCredentialW}
  640. function CredUnmarshalCredential(MarshaledCredential: LPCTSTR; CredType: PCRED_MARSHAL_TYPE; var Credential: PVOID): BOOL; stdcall;
  641. {$EXTERNALSYM CredUnmarshalCredential}
  642. function CredIsMarshaledCredentialA(MarshaledCredential: LPCSTR): BOOL; stdcall;
  643. {$EXTERNALSYM CredIsMarshaledCredentialA}
  644. function CredIsMarshaledCredentialW(MarshaledCredential: LPCWSTR): BOOL; stdcall;
  645. {$EXTERNALSYM CredIsMarshaledCredentialW}
  646. function CredIsMarshaledCredential(MarshaledCredential: LPCTSTR): BOOL; stdcall;
  647. {$EXTERNALSYM CredIsMarshaledCredential}
  648. function CredGetSessionTypes(MaximumPersistCount: DWORD; MaximumPersist: LPDWORD): BOOL; stdcall;
  649. {$EXTERNALSYM CredGetSessionTypes}
  650. procedure CredFree(Buffer: PVOID); stdcall;
  651. {$EXTERNALSYM CredFree}
  652. 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;
  653. {$EXTERNALSYM CredUIPromptForCredentialsA}
  654. 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;
  655. {$EXTERNALSYM CredUIPromptForCredentialsW}
  656. 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;
  657. {$EXTERNALSYM CredUIPromptForCredentials}
  658. function CredUIParseUserNameA(pszUserName: PCSTR; pszUser: PSTR; ulUserBufferSize: ULONG; pszDomain: PSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  659. {$EXTERNALSYM CredUIParseUserNameA}
  660. function CredUIParseUserNameW(pszUserName: LPCWSTR; pszUser: PWSTR; ulUserBufferSize: ULONG; pszDomain: PWSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  661. {$EXTERNALSYM CredUIParseUserNameW}
  662. function CredUIParseUserName(pszUserName: LPCTSTR; pszUser: PTSTR; ulUserBufferSize: ULONG; pszDomain: PTSTR; ulDomainBufferSize: ULONG): DWORD; stdcall;
  663. {$EXTERNALSYM CredUIParseUserName}
  664. function CredUICmdLinePromptForCredentialsA(pszTargetName: PCSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PSTR; ulUserBufferSize: ULONG; pszPassword: PSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  665. {$EXTERNALSYM CredUICmdLinePromptForCredentialsA}
  666. function CredUICmdLinePromptForCredentialsW(pszTargetName: LPCWSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PWSTR; ulUserBufferSize: ULONG; pszPassword: PWSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  667. {$EXTERNALSYM CredUICmdLinePromptForCredentialsW}
  668. function CredUICmdLinePromptForCredentials(pszTargetName: LPCTSTR; pContext: PCtxtHandle; dwAuthError: DWORD; UserName: PTSTR; ulUserBufferSize: ULONG; pszPassword: PTSTR; ulPasswordBufferSize: ULONG; pfSave: PBOOL; dwFlags: DWORD): DWORD; stdcall;
  669. {$EXTERNALSYM CredUICmdLinePromptForCredentials}
  670. //
  671. // Call this API with bConfirm set to TRUE to confirm that the credential (previously created
  672. // via CredUIGetCredentials or CredUIPromptForCredentials worked, or with bConfirm set to FALSE
  673. // to indicate it didn't
  674. function CredUIConfirmCredentialsA(pszTargetName: PCSTR; bConfirm: BOOL): DWORD; stdcall;
  675. {$EXTERNALSYM CredUIConfirmCredentialsA}
  676. function CredUIConfirmCredentialsW(pszTargetName: LPCWSTR; bConfirm: BOOL): DWORD; stdcall;
  677. {$EXTERNALSYM CredUIConfirmCredentialsW}
  678. function CredUIConfirmCredentials(pszTargetName: LPCTSTR; bConfirm: BOOL): DWORD; stdcall;
  679. {$EXTERNALSYM CredUIConfirmCredentials}
  680. function CredUIStoreSSOCredW(pszRealm, pszUsername, pszPassword: LPCWSTR; bPersist: BOOL): DWORD; stdcall;
  681. {$EXTERNALSYM CredUIStoreSSOCredW}
  682. function CredUIReadSSOCredW(pszRealm: LPCWSTR; out ppszUsername: PWSTR): DWORD; stdcall;
  683. {$EXTERNALSYM CredUIReadSSOCredW}
  684. implementation
  685. uses
  686. JwaWinDLLNames;
  687. function CREDUIP_IS_USER_PASSWORD_ERROR(_Status: NTSTATUS): BOOL;
  688. begin
  689. Result :=
  690. (DWORD(_Status) = ERROR_LOGON_FAILURE) or
  691. (_Status = HRESULT_FROM_WIN32(ERROR_LOGON_FAILURE)) or
  692. (_Status = STATUS_LOGON_FAILURE) or
  693. (_Status = HRESULT_FROM_NT(STATUS_LOGON_FAILURE)) or
  694. (DWORD(_Status) = ERROR_ACCESS_DENIED) or
  695. (_Status = HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED)) or
  696. (_Status = STATUS_ACCESS_DENIED) or
  697. (_Status = HRESULT_FROM_NT(STATUS_ACCESS_DENIED)) or
  698. (DWORD(_Status) = ERROR_INVALID_PASSWORD) or
  699. (_Status = HRESULT_FROM_WIN32(ERROR_INVALID_PASSWORD)) or
  700. (_Status = STATUS_WRONG_PASSWORD) or
  701. (_Status = HRESULT_FROM_NT(STATUS_WRONG_PASSWORD)) or
  702. (_Status = SEC_E_NO_CREDENTIALS) or
  703. (_Status = SEC_E_LOGON_DENIED);
  704. end;
  705. function CREDUIP_IS_DOWNGRADE_ERROR(_Status: NTSTATUS): BOOL;
  706. begin
  707. Result :=
  708. (DWORD(_Status) = ERROR_DOWNGRADE_DETECTED) or
  709. (_Status = HRESULT_FROM_WIN32(ERROR_DOWNGRADE_DETECTED)) or
  710. (_Status = STATUS_DOWNGRADE_DETECTED) or
  711. (_Status = HRESULT_FROM_NT(STATUS_DOWNGRADE_DETECTED))
  712. end;
  713. function CREDUIP_IS_EXPIRED_ERROR(_Status: NTSTATUS): BOOL;
  714. begin
  715. Result :=
  716. (DWORD(_Status) = ERROR_PASSWORD_EXPIRED) or
  717. (_Status = HRESULT_FROM_WIN32( ERROR_PASSWORD_EXPIRED)) or
  718. (_Status = STATUS_PASSWORD_EXPIRED) or
  719. (_Status = HRESULT_FROM_NT( STATUS_PASSWORD_EXPIRED)) or
  720. (DWORD(_Status) = ERROR_PASSWORD_MUST_CHANGE) or
  721. (_Status = HRESULT_FROM_WIN32( ERROR_PASSWORD_MUST_CHANGE)) or
  722. (_Status = STATUS_PASSWORD_MUST_CHANGE) or
  723. (_Status = HRESULT_FROM_NT( STATUS_PASSWORD_MUST_CHANGE)) or
  724. (_Status = NERR_PasswordExpired) or
  725. (_Status = HRESULT_FROM_WIN32(NERR_PasswordExpired));
  726. end;
  727. function CREDUI_IS_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  728. begin
  729. Result := CREDUIP_IS_USER_PASSWORD_ERROR(_Status) or CREDUIP_IS_DOWNGRADE_ERROR(_Status) or CREDUIP_IS_EXPIRED_ERROR(_Status);
  730. end;
  731. function CREDUI_NO_PROMPT_AUTHENTICATION_ERROR(_Status: NTSTATUS): BOOL;
  732. begin
  733. Result :=
  734. (_Status = NTSTATUS(ERROR_AUTHENTICATION_FIREWALL_FAILED)) or
  735. (_Status = HRESULT_FROM_WIN32(ERROR_AUTHENTICATION_FIREWALL_FAILED)) or
  736. (_Status = STATUS_AUTHENTICATION_FIREWALL_FAILED) or
  737. (_Status = HRESULT_FROM_NT(STATUS_AUTHENTICATION_FIREWALL_FAILED)) or
  738. (DWORD(_Status) = ERROR_ACCOUNT_DISABLED) or
  739. (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_DISABLED)) or
  740. (_Status = STATUS_ACCOUNT_DISABLED) or
  741. (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_DISABLED)) or
  742. (DWORD(_Status) = ERROR_ACCOUNT_RESTRICTION) or
  743. (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_RESTRICTION)) or
  744. (_Status = STATUS_ACCOUNT_RESTRICTION) or
  745. (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_RESTRICTION)) or
  746. (DWORD(_Status) = ERROR_ACCOUNT_LOCKED_OUT) or
  747. (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_LOCKED_OUT)) or
  748. (_Status = STATUS_ACCOUNT_LOCKED_OUT) or
  749. (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_LOCKED_OUT)) or
  750. (DWORD(_Status) = ERROR_ACCOUNT_EXPIRED) or
  751. (_Status = HRESULT_FROM_WIN32(ERROR_ACCOUNT_EXPIRED)) or
  752. (_Status = STATUS_ACCOUNT_EXPIRED) or
  753. (_Status = HRESULT_FROM_NT(STATUS_ACCOUNT_EXPIRED)) or
  754. (DWORD(_Status) = ERROR_LOGON_TYPE_NOT_GRANTED) or
  755. (_Status = HRESULT_FROM_WIN32(ERROR_LOGON_TYPE_NOT_GRANTED)) or
  756. (_Status = STATUS_LOGON_TYPE_NOT_GRANTED) or
  757. (_Status = HRESULT_FROM_NT(STATUS_LOGON_TYPE_NOT_GRANTED));
  758. end;
  759. {$IFDEF DYNAMIC_LINK}
  760. var
  761. _CredWriteW: Pointer;
  762. function CredWriteW;
  763. begin
  764. GetProcedureAddress(_CredWriteW, credapi, 'CredWriteW');
  765. asm
  766. MOV ESP, EBP
  767. POP EBP
  768. JMP [_CredWriteW]
  769. end;
  770. end;
  771. var
  772. _CredWriteA: Pointer;
  773. function CredWriteA;
  774. begin
  775. GetProcedureAddress(_CredWriteA, credapi, 'CredWriteA');
  776. asm
  777. MOV ESP, EBP
  778. POP EBP
  779. JMP [_CredWriteA]
  780. end;
  781. end;
  782. var
  783. _CredWrite: Pointer;
  784. function CredWrite;
  785. begin
  786. GetProcedureAddress(_CredWrite, credapi, 'CredWrite' + AWSuffix);
  787. asm
  788. MOV ESP, EBP
  789. POP EBP
  790. JMP [_CredWrite]
  791. end;
  792. end;
  793. var
  794. _CredReadW: Pointer;
  795. function CredReadW;
  796. begin
  797. GetProcedureAddress(_CredReadW, credapi, 'CredReadW');
  798. asm
  799. MOV ESP, EBP
  800. POP EBP
  801. JMP [_CredReadW]
  802. end;
  803. end;
  804. var
  805. _CredReadA: Pointer;
  806. function CredReadA;
  807. begin
  808. GetProcedureAddress(_CredReadA, credapi, 'CredReadA');
  809. asm
  810. MOV ESP, EBP
  811. POP EBP
  812. JMP [_CredReadA]
  813. end;
  814. end;
  815. var
  816. _CredRead: Pointer;
  817. function CredRead;
  818. begin
  819. GetProcedureAddress(_CredRead, credapi, 'CredRead' + AWSuffix);
  820. asm
  821. MOV ESP, EBP
  822. POP EBP
  823. JMP [_CredRead]
  824. end;
  825. end;
  826. var
  827. _CredEnumerateW: Pointer;
  828. function CredEnumerateW;
  829. begin
  830. GetProcedureAddress(_CredEnumerateW, credapi, 'CredEnumerateW');
  831. asm
  832. MOV ESP, EBP
  833. POP EBP
  834. JMP [_CredEnumerateW]
  835. end;
  836. end;
  837. var
  838. _CredEnumerateA: Pointer;
  839. function CredEnumerateA;
  840. begin
  841. GetProcedureAddress(_CredEnumerateA, credapi, 'CredEnumerateA');
  842. asm
  843. MOV ESP, EBP
  844. POP EBP
  845. JMP [_CredEnumerateA]
  846. end;
  847. end;
  848. var
  849. _CredEnumerate: Pointer;
  850. function CredEnumerate;
  851. begin
  852. GetProcedureAddress(_CredEnumerate, credapi, 'CredEnumerate' + AWSuffix);
  853. asm
  854. MOV ESP, EBP
  855. POP EBP
  856. JMP [_CredEnumerate]
  857. end;
  858. end;
  859. var
  860. _CredWriteDomainCredentialsW: Pointer;
  861. function CredWriteDomainCredentialsW;
  862. begin
  863. GetProcedureAddress(_CredWriteDomainCredentialsW, credapi, 'CredWriteDomainCredentialsW');
  864. asm
  865. MOV ESP, EBP
  866. POP EBP
  867. JMP [_CredWriteDomainCredentialsW]
  868. end;
  869. end;
  870. var
  871. _CredWriteDomainCredentialsA: Pointer;
  872. function CredWriteDomainCredentialsA;
  873. begin
  874. GetProcedureAddress(_CredWriteDomainCredentialsA, credapi, 'CredWriteDomainCredentialsA');
  875. asm
  876. MOV ESP, EBP
  877. POP EBP
  878. JMP [_CredWriteDomainCredentialsA]
  879. end;
  880. end;
  881. var
  882. _CredWriteDomainCredentials: Pointer;
  883. function CredWriteDomainCredentials;
  884. begin
  885. GetProcedureAddress(_CredWriteDomainCredentials, credapi, 'CredWriteDomainCredentials' + AWSuffix);
  886. asm
  887. MOV ESP, EBP
  888. POP EBP
  889. JMP [_CredWriteDomainCredentials]
  890. end;
  891. end;
  892. var
  893. _CredReadDomainCredentialsW: Pointer;
  894. function CredReadDomainCredentialsW;
  895. begin
  896. GetProcedureAddress(_CredReadDomainCredentialsW, credapi, 'CredReadDomainCredentialsW');
  897. asm
  898. MOV ESP, EBP
  899. POP EBP
  900. JMP [_CredReadDomainCredentialsW]
  901. end;
  902. end;
  903. var
  904. _CredReadDomainCredentialsA: Pointer;
  905. function CredReadDomainCredentialsA;
  906. begin
  907. GetProcedureAddress(_CredReadDomainCredentialsA, credapi, 'CredReadDomainCredentialsA');
  908. asm
  909. MOV ESP, EBP
  910. POP EBP
  911. JMP [_CredReadDomainCredentialsA]
  912. end;
  913. end;
  914. var
  915. _CredReadDomainCredentials: Pointer;
  916. function CredReadDomainCredentials;
  917. begin
  918. GetProcedureAddress(_CredReadDomainCredentials, credapi, 'CredReadDomainCredentials' + AWSuffix);
  919. asm
  920. MOV ESP, EBP
  921. POP EBP
  922. JMP [_CredReadDomainCredentials]
  923. end;
  924. end;
  925. var
  926. _CredDeleteW: Pointer;
  927. function CredDeleteW;
  928. begin
  929. GetProcedureAddress(_CredDeleteW, credapi, 'CredDeleteW');
  930. asm
  931. MOV ESP, EBP
  932. POP EBP
  933. JMP [_CredDeleteW]
  934. end;
  935. end;
  936. var
  937. _CredDeleteA: Pointer;
  938. function CredDeleteA;
  939. begin
  940. GetProcedureAddress(_CredDeleteA, credapi, 'CredDeleteA');
  941. asm
  942. MOV ESP, EBP
  943. POP EBP
  944. JMP [_CredDeleteA]
  945. end;
  946. end;
  947. var
  948. _CredDelete: Pointer;
  949. function CredDelete;
  950. begin
  951. GetProcedureAddress(_CredDelete, credapi, 'CredDelete' + AWSuffix);
  952. asm
  953. MOV ESP, EBP
  954. POP EBP
  955. JMP [_CredDelete]
  956. end;
  957. end;
  958. var
  959. _CredRenameW: Pointer;
  960. function CredRenameW;
  961. begin
  962. GetProcedureAddress(_CredRenameW, credapi, 'CredRenameW');
  963. asm
  964. MOV ESP, EBP
  965. POP EBP
  966. JMP [_CredRenameW]
  967. end;
  968. end;
  969. var
  970. _CredRenameA: Pointer;
  971. function CredRenameA;
  972. begin
  973. GetProcedureAddress(_CredRenameA, credapi, 'CredRenameA');
  974. asm
  975. MOV ESP, EBP
  976. POP EBP
  977. JMP [_CredRenameA]
  978. end;
  979. end;
  980. var
  981. _CredRename: Pointer;
  982. function CredRename;
  983. begin
  984. GetProcedureAddress(_CredRename, credapi, 'CredRename' + AWSuffix);
  985. asm
  986. MOV ESP, EBP
  987. POP EBP
  988. JMP [_CredRename]
  989. end;
  990. end;
  991. var
  992. _CredGetTargetInfoW: Pointer;
  993. function CredGetTargetInfoW;
  994. begin
  995. GetProcedureAddress(_CredGetTargetInfoW, credapi, 'CredGetTargetInfoW');
  996. asm
  997. MOV ESP, EBP
  998. POP EBP
  999. JMP [_CredGetTargetInfoW]
  1000. end;
  1001. end;
  1002. var
  1003. _CredGetTargetInfoA: Pointer;
  1004. function CredGetTargetInfoA;
  1005. begin
  1006. GetProcedureAddress(_CredGetTargetInfoA, credapi, 'CredGetTargetInfoA');
  1007. asm
  1008. MOV ESP, EBP
  1009. POP EBP
  1010. JMP [_CredGetTargetInfoA]
  1011. end;
  1012. end;
  1013. var
  1014. _CredGetTargetInfo: Pointer;
  1015. function CredGetTargetInfo;
  1016. begin
  1017. GetProcedureAddress(_CredGetTargetInfo, credapi, 'CredGetTargetInfoA');
  1018. asm
  1019. MOV ESP, EBP
  1020. POP EBP
  1021. JMP [_CredGetTargetInfo]
  1022. end;
  1023. end;
  1024. var
  1025. _CredMarshalCredentialW: Pointer;
  1026. function CredMarshalCredentialW;
  1027. begin
  1028. GetProcedureAddress(_CredMarshalCredentialW, credapi, 'CredMarshalCredentialW');
  1029. asm
  1030. MOV ESP, EBP
  1031. POP EBP
  1032. JMP [_CredMarshalCredentialW]
  1033. end;
  1034. end;
  1035. var
  1036. _CredMarshalCredentialA: Pointer;
  1037. function CredMarshalCredentialA;
  1038. begin
  1039. GetProcedureAddress(_CredMarshalCredentialA, credapi, 'CredMarshalCredentialA');
  1040. asm
  1041. MOV ESP, EBP
  1042. POP EBP
  1043. JMP [_CredMarshalCredentialA]
  1044. end;
  1045. end;
  1046. var
  1047. _CredMarshalCredential: Pointer;
  1048. function CredMarshalCredential;
  1049. begin
  1050. GetProcedureAddress(_CredMarshalCredential, credapi, 'CredMarshalCredential' + AWSuffix);
  1051. asm
  1052. MOV ESP, EBP
  1053. POP EBP
  1054. JMP [_CredMarshalCredential]
  1055. end;
  1056. end;
  1057. var
  1058. _CredUnmarshalCredentialW: Pointer;
  1059. function CredUnmarshalCredentialW;
  1060. begin
  1061. GetProcedureAddress(_CredUnmarshalCredentialW, credapi, 'CredUnmarshalCredentialW');
  1062. asm
  1063. MOV ESP, EBP
  1064. POP EBP
  1065. JMP [_CredUnmarshalCredentialW]
  1066. end;
  1067. end;
  1068. var
  1069. _CredUnmarshalCredentialA: Pointer;
  1070. function CredUnmarshalCredentialA;
  1071. begin
  1072. GetProcedureAddress(_CredUnmarshalCredentialA, credapi, 'CredUnmarshalCredentialA');
  1073. asm
  1074. MOV ESP, EBP
  1075. POP EBP
  1076. JMP [_CredUnmarshalCredentialA]
  1077. end;
  1078. end;
  1079. var
  1080. _CredUnmarshalCredential: Pointer;
  1081. function CredUnmarshalCredential;
  1082. begin
  1083. GetProcedureAddress(_CredUnmarshalCredential, credapi, 'CredUnmarshalCredential' + AWSuffix);
  1084. asm
  1085. MOV ESP, EBP
  1086. POP EBP
  1087. JMP [_CredUnmarshalCredential]
  1088. end;
  1089. end;
  1090. var
  1091. _CredIsMarshaledCredentialW: Pointer;
  1092. function CredIsMarshaledCredentialW;
  1093. begin
  1094. GetProcedureAddress(_CredIsMarshaledCredentialW, credapi, 'CredIsMarshaledCredentialW');
  1095. asm
  1096. MOV ESP, EBP
  1097. POP EBP
  1098. JMP [_CredIsMarshaledCredentialW]
  1099. end;
  1100. end;
  1101. var
  1102. _CredIsMarshaledCredentialA: Pointer;
  1103. function CredIsMarshaledCredentialA;
  1104. begin
  1105. GetProcedureAddress(_CredIsMarshaledCredentialA, credapi, 'CredIsMarshaledCredentialA');
  1106. asm
  1107. MOV ESP, EBP
  1108. POP EBP
  1109. JMP [_CredIsMarshaledCredentialA]
  1110. end;
  1111. end;
  1112. var
  1113. _CredIsMarshaledCredential: Pointer;
  1114. function CredIsMarshaledCredential;
  1115. begin
  1116. GetProcedureAddress(_CredIsMarshaledCredential, credapi, 'CredIsMarshaledCredential' + AWSuffix);
  1117. asm
  1118. MOV ESP, EBP
  1119. POP EBP
  1120. JMP [_CredIsMarshaledCredential]
  1121. end;
  1122. end;
  1123. var
  1124. _CredGetSessionTypes: Pointer;
  1125. function CredGetSessionTypes;
  1126. begin
  1127. GetProcedureAddress(_CredGetSessionTypes, credapi, 'CredGetSessionTypes');
  1128. asm
  1129. MOV ESP, EBP
  1130. POP EBP
  1131. JMP [_CredGetSessionTypes]
  1132. end;
  1133. end;
  1134. var
  1135. _CredFree: Pointer;
  1136. procedure CredFree;
  1137. begin
  1138. GetProcedureAddress(_CredFree, credapi, 'CredFree');
  1139. asm
  1140. MOV ESP, EBP
  1141. POP EBP
  1142. JMP [_CredFree]
  1143. end;
  1144. end;
  1145. var
  1146. _CredUIPromptForCredentialsW: Pointer;
  1147. function CredUIPromptForCredentialsW;
  1148. begin
  1149. GetProcedureAddress(_CredUIPromptForCredentialsW, credui, 'CredUIPromptForCredentialsW');
  1150. asm
  1151. MOV ESP, EBP
  1152. POP EBP
  1153. JMP [_CredUIPromptForCredentialsW]
  1154. end;
  1155. end;
  1156. var
  1157. _CredUIPromptForCredentialsA: Pointer;
  1158. function CredUIPromptForCredentialsA;
  1159. begin
  1160. GetProcedureAddress(_CredUIPromptForCredentialsA, credui, 'CredUIPromptForCredentialsA');
  1161. asm
  1162. MOV ESP, EBP
  1163. POP EBP
  1164. JMP [_CredUIPromptForCredentialsA]
  1165. end;
  1166. end;
  1167. var
  1168. _CredUIPromptForCredentials: Pointer;
  1169. function CredUIPromptForCredentials;
  1170. begin
  1171. GetProcedureAddress(_CredUIPromptForCredentials, credui, 'CredUIPromptForCredentials' + AWSuffix);
  1172. asm
  1173. MOV ESP, EBP
  1174. POP EBP
  1175. JMP [_CredUIPromptForCredentials]
  1176. end;
  1177. end;
  1178. var
  1179. _CredUIParseUserNameW: Pointer;
  1180. function CredUIParseUserNameW;
  1181. begin
  1182. GetProcedureAddress(_CredUIParseUserNameW, credui, 'CredUIParseUserNameW');
  1183. asm
  1184. MOV ESP, EBP
  1185. POP EBP
  1186. JMP [_CredUIParseUserNameW]
  1187. end;
  1188. end;
  1189. var
  1190. _CredUIParseUserNameA: Pointer;
  1191. function CredUIParseUserNameA;
  1192. begin
  1193. GetProcedureAddress(_CredUIParseUserNameA, credui, 'CredUIParseUserNameA');
  1194. asm
  1195. MOV ESP, EBP
  1196. POP EBP
  1197. JMP [_CredUIParseUserNameA]
  1198. end;
  1199. end;
  1200. var
  1201. _CredUIParseUserName: Pointer;
  1202. function CredUIParseUserName;
  1203. begin
  1204. GetProcedureAddress(_CredUIParseUserName, credui, 'CredUIParseUserName' + AWSuffix);
  1205. asm
  1206. MOV ESP, EBP
  1207. POP EBP
  1208. JMP [_CredUIParseUserName]
  1209. end;
  1210. end;
  1211. var
  1212. _CredUICmdLinePromptForCredentialsW: Pointer;
  1213. function CredUICmdLinePromptForCredentialsW;
  1214. begin
  1215. GetProcedureAddress(_CredUICmdLinePromptForCredentialsW, credui, 'CredUICmdLinePromptForCredentialsW');
  1216. asm
  1217. MOV ESP, EBP
  1218. POP EBP
  1219. JMP [_CredUICmdLinePromptForCredentialsW]
  1220. end;
  1221. end;
  1222. var
  1223. _CredUICmdLinePromptForCredentialsA: Pointer;
  1224. function CredUICmdLinePromptForCredentialsA;
  1225. begin
  1226. GetProcedureAddress(_CredUICmdLinePromptForCredentialsA, credui, 'CredUICmdLinePromptForCredentialsA');
  1227. asm
  1228. MOV ESP, EBP
  1229. POP EBP
  1230. JMP [_CredUICmdLinePromptForCredentialsA]
  1231. end;
  1232. end;
  1233. var
  1234. _CredUICmdLinePromptForCredentials: Pointer;
  1235. function CredUICmdLinePromptForCredentials;
  1236. begin
  1237. GetProcedureAddress(_CredUICmdLinePromptForCredentials, credui, 'CredUICmdLinePromptForCredentials' + AWSuffix);
  1238. asm
  1239. MOV ESP, EBP
  1240. POP EBP
  1241. JMP [_CredUICmdLinePromptForCredentials]
  1242. end;
  1243. end;
  1244. var
  1245. _CredUIConfirmCredentialsW: Pointer;
  1246. function CredUIConfirmCredentialsW;
  1247. begin
  1248. GetProcedureAddress(_CredUIConfirmCredentialsW, credui, 'CredUIConfirmCredentialsW');
  1249. asm
  1250. MOV ESP, EBP
  1251. POP EBP
  1252. JMP [_CredUIConfirmCredentialsW]
  1253. end;
  1254. end;
  1255. var
  1256. _CredUIConfirmCredentialsA: Pointer;
  1257. function CredUIConfirmCredentialsA;
  1258. begin
  1259. GetProcedureAddress(_CredUIConfirmCredentialsA, credui, 'CredUIConfirmCredentialsA');
  1260. asm
  1261. MOV ESP, EBP
  1262. POP EBP
  1263. JMP [_CredUIConfirmCredentialsA]
  1264. end;
  1265. end;
  1266. var
  1267. _CredUIConfirmCredentials: Pointer;
  1268. function CredUIConfirmCredentials;
  1269. begin
  1270. GetProcedureAddress(_CredUIConfirmCredentials, credui, 'CredUIConfirmCredentials' + AWSuffix);
  1271. asm
  1272. MOV ESP, EBP
  1273. POP EBP
  1274. JMP [_CredUIConfirmCredentials]
  1275. end;
  1276. end;
  1277. var
  1278. _CredUIStoreSSOCredW: Pointer;
  1279. function CredUIStoreSSOCredW;
  1280. begin
  1281. GetProcedureAddress(_CredUIStoreSSOCredW, credui, 'CredUIStoreSSOCredW');
  1282. asm
  1283. MOV ESP, EBP
  1284. POP EBP
  1285. JMP [_CredUIStoreSSOCredW]
  1286. end;
  1287. end;
  1288. var
  1289. _CredUIReadSSOCredW: Pointer;
  1290. function CredUIReadSSOCredW;
  1291. begin
  1292. GetProcedureAddress(_CredUIReadSSOCredW, credui, 'CredUIReadSSOCredW');
  1293. asm
  1294. MOV ESP, EBP
  1295. POP EBP
  1296. JMP [_CredUIReadSSOCredW]
  1297. end;
  1298. end;
  1299. {$ELSE}
  1300. function CredWriteW; external credapi name 'CredWriteW';
  1301. function CredWriteA; external credapi name 'CredWriteA';
  1302. function CredWrite; external credapi name 'CredWrite' + AWSuffix;
  1303. function CredReadW; external credapi name 'CredReadW';
  1304. function CredReadA; external credapi name 'CredReadA';
  1305. function CredRead; external credapi name 'CredRead' + AWSuffix;
  1306. function CredEnumerateW; external credapi name 'CredEnumerateW';
  1307. function CredEnumerateA; external credapi name 'CredEnumerateA';
  1308. function CredEnumerate; external credapi name 'CredEnumerate' + AWSuffix;
  1309. function CredWriteDomainCredentialsW; external credapi name 'CredWriteDomainCredentialsW';
  1310. function CredWriteDomainCredentialsA; external credapi name 'CredWriteDomainCredentialsA';
  1311. function CredWriteDomainCredentials; external credapi name 'CredWriteDomainCredentials' + AWSuffix;
  1312. function CredReadDomainCredentialsW; external credapi name 'CredReadDomainCredentialsW';
  1313. function CredReadDomainCredentialsA; external credapi name 'CredReadDomainCredentialsA';
  1314. function CredReadDomainCredentials; external credapi name 'CredReadDomainCredentials' + AWSuffix;
  1315. function CredDeleteW; external credapi name 'CredDeleteW';
  1316. function CredDeleteA; external credapi name 'CredDeleteA';
  1317. function CredDelete; external credapi name 'CredDelete' + AWSuffix;
  1318. function CredRenameW; external credapi name 'CredRenameW';
  1319. function CredRenameA; external credapi name 'CredRenameA';
  1320. function CredRename; external credapi name 'CredRename' + AWSuffix;
  1321. function CredGetTargetInfoW; external credapi name 'CredGetTargetInfoW';
  1322. function CredGetTargetInfoA; external credapi name 'CredGetTargetInfoA';
  1323. function CredGetTargetInfo; external credapi name 'CredGetTargetInfoA';
  1324. function CredMarshalCredentialW; external credapi name 'CredMarshalCredentialW';
  1325. function CredMarshalCredentialA; external credapi name 'CredMarshalCredentialA';
  1326. function CredMarshalCredential; external credapi name 'CredMarshalCredential' + AWSuffix;
  1327. function CredUnmarshalCredentialW; external credapi name 'CredUnmarshalCredentialW';
  1328. function CredUnmarshalCredentialA; external credapi name 'CredUnmarshalCredentialA';
  1329. function CredUnmarshalCredential; external credapi name 'CredUnmarshalCredential' + AWSuffix;
  1330. function CredIsMarshaledCredentialW; external credapi name 'CredIsMarshaledCredentialW';
  1331. function CredIsMarshaledCredentialA; external credapi name 'CredIsMarshaledCredentialA';
  1332. function CredIsMarshaledCredential; external credapi name 'CredIsMarshaledCredential' + AWSuffix;
  1333. function CredGetSessionTypes; external credapi name 'CredGetSessionTypes';
  1334. procedure CredFree; external credapi name 'CredFree';
  1335. function CredUIPromptForCredentialsW; external credui name 'CredUIPromptForCredentialsW';
  1336. function CredUIPromptForCredentialsA; external credui name 'CredUIPromptForCredentialsA';
  1337. function CredUIPromptForCredentials; external credui name 'CredUIPromptForCredentials' + AWSuffix;
  1338. function CredUIParseUserNameW; external credui name 'CredUIParseUserNameW';
  1339. function CredUIParseUserNameA; external credui name 'CredUIParseUserNameA';
  1340. function CredUIParseUserName; external credui name 'CredUIParseUserName' + AWSuffix;
  1341. function CredUICmdLinePromptForCredentialsW; external credui name 'CredUICmdLinePromptForCredentialsW';
  1342. function CredUICmdLinePromptForCredentialsA; external credui name 'CredUICmdLinePromptForCredentialsA';
  1343. function CredUICmdLinePromptForCredentials; external credui name 'CredUICmdLinePromptForCredentials' + AWSuffix;
  1344. function CredUIConfirmCredentialsW; external credui name 'CredUIConfirmCredentialsW';
  1345. function CredUIConfirmCredentialsA; external credui name 'CredUIConfirmCredentialsA';
  1346. function CredUIConfirmCredentials; external credui name 'CredUIConfirmCredentials' + AWSuffix;
  1347. function CredUIStoreSSOCredW; external credui name 'CredUIStoreSSOCredW';
  1348. function CredUIReadSSOCredW; external credui name 'CredUIReadSSOCredW';
  1349. {$ENDIF DYNAMIC_LINK}
  1350. end.