1 /* 2 * Copyright (C) 2006 Robert Shearman (for CodeWeavers) 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 */ 18 19 #ifndef _WINCRED_H_ 20 #define _WINCRED_H_ 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #ifdef _ADVAPI32_ 27 #define WINADVAPI 28 #else 29 #define WINADVAPI DECLSPEC_IMPORT 30 #endif 31 32 #ifndef __SECHANDLE_DEFINED__ 33 #define __SECHANDLE_DEFINED__ 34 typedef struct _SecHandle 35 { 36 ULONG_PTR dwLower; 37 ULONG_PTR dwUpper; 38 } SecHandle, *PSecHandle; 39 #endif 40 41 #ifndef __WINE_CTXTHANDLE_DEFINED__ 42 #define __WINE_CTXTHANDLE_DEFINED__ 43 typedef SecHandle CtxtHandle; 44 typedef PSecHandle PCtxtHandle; 45 #endif 46 47 typedef struct _CREDENTIAL_ATTRIBUTEA 48 { 49 LPSTR Keyword; 50 DWORD Flags; 51 DWORD ValueSize; 52 LPBYTE Value; 53 } CREDENTIAL_ATTRIBUTEA, *PCREDENTIAL_ATTRIBUTEA; 54 55 typedef struct _CREDENTIAL_ATTRIBUTEW 56 { 57 LPWSTR Keyword; 58 DWORD Flags; 59 DWORD ValueSize; 60 LPBYTE Value; 61 } CREDENTIAL_ATTRIBUTEW, *PCREDENTIAL_ATTRIBUTEW; 62 63 DECL_WINELIB_TYPE_AW(CREDENTIAL_ATTRIBUTE) 64 DECL_WINELIB_TYPE_AW(PCREDENTIAL_ATTRIBUTE) 65 66 typedef struct _CREDENTIALA 67 { 68 DWORD Flags; 69 DWORD Type; 70 LPSTR TargetName; 71 LPSTR Comment; 72 FILETIME LastWritten; 73 DWORD CredentialBlobSize; 74 _Field_size_bytes_(CredentialBlobSize) LPBYTE CredentialBlob; 75 DWORD Persist; 76 DWORD AttributeCount; 77 PCREDENTIAL_ATTRIBUTEA Attributes; 78 LPSTR TargetAlias; 79 LPSTR UserName; 80 } CREDENTIALA, *PCREDENTIALA; 81 82 typedef struct _CREDENTIALW 83 { 84 DWORD Flags; 85 DWORD Type; 86 LPWSTR TargetName; 87 LPWSTR Comment; 88 FILETIME LastWritten; 89 DWORD CredentialBlobSize; 90 LPBYTE CredentialBlob; 91 DWORD Persist; 92 DWORD AttributeCount; 93 PCREDENTIAL_ATTRIBUTEW Attributes; 94 LPWSTR TargetAlias; 95 LPWSTR UserName; 96 } CREDENTIALW, *PCREDENTIALW; 97 98 DECL_WINELIB_TYPE_AW(CREDENTIAL) 99 DECL_WINELIB_TYPE_AW(PCREDENTIAL) 100 101 typedef struct _CREDENTIAL_TARGET_INFORMATIONA 102 { 103 LPSTR TargetName; 104 LPSTR NetbiosServerName; 105 LPSTR DnsServerName; 106 LPSTR NetbiosDomainName; 107 LPSTR DnsDomainName; 108 LPSTR DnsTreeName; 109 LPSTR PackageName; 110 DWORD Flags; 111 DWORD CredTypeCount; 112 LPDWORD CredTypes; 113 } CREDENTIAL_TARGET_INFORMATIONA, *PCREDENTIAL_TARGET_INFORMATIONA; 114 115 typedef struct _CREDENTIAL_TARGET_INFORMATIONW 116 { 117 LPWSTR TargetName; 118 LPWSTR NetbiosServerName; 119 LPWSTR DnsServerName; 120 LPWSTR NetbiosDomainName; 121 LPWSTR DnsDomainName; 122 LPWSTR DnsTreeName; 123 LPWSTR PackageName; 124 DWORD Flags; 125 DWORD CredTypeCount; 126 LPDWORD CredTypes; 127 } CREDENTIAL_TARGET_INFORMATIONW, *PCREDENTIAL_TARGET_INFORMATIONW; 128 129 DECL_WINELIB_TYPE_AW(CREDENTIAL_TARGET_INFORMATION) 130 DECL_WINELIB_TYPE_AW(PCREDENTIAL_TARGET_INFORMATION) 131 132 typedef struct _CREDUI_INFOA 133 { 134 DWORD cbSize; 135 HWND hwndParent; 136 PCSTR pszMessageText; 137 PCSTR pszCaptionText; 138 HBITMAP hbmBanner; 139 } CREDUI_INFOA, *PCREDUI_INFOA; 140 141 typedef struct _CREDUI_INFOW 142 { 143 DWORD cbSize; 144 HWND hwndParent; 145 PCWSTR pszMessageText; 146 PCWSTR pszCaptionText; 147 HBITMAP hbmBanner; 148 } CREDUI_INFOW, *PCREDUI_INFOW; 149 150 DECL_WINELIB_TYPE_AW(CREDUI_INFO) 151 DECL_WINELIB_TYPE_AW(PCREDUI_INFO) 152 153 typedef enum _CRED_MARSHAL_TYPE 154 { 155 CertCredential = 1, 156 UsernameTargetCredential, 157 BinaryBlobCredential 158 } CRED_MARSHAL_TYPE, *PCRED_MARSHAL_TYPE; 159 160 #define CERT_HASH_LENGTH 20 161 162 typedef struct _CERT_CREDENTIAL_INFO 163 { 164 ULONG cbSize; 165 UCHAR rgbHashOfCert[CERT_HASH_LENGTH]; 166 } CERT_CREDENTIAL_INFO, *PCERT_CREDENTIAL_INFO; 167 168 typedef struct _USERNAME_TARGET_CREDENTIAL_INFO 169 { 170 LPWSTR UserName; 171 } USERNAME_TARGET_CREDENTIAL_INFO; 172 173 typedef struct _BINARY_BLOB_CREDENTIAL_INFO 174 { 175 ULONG cbBlob; 176 LPBYTE pbBlob; 177 } BINARY_BLOB_CREDENTIAL_INFO, *PBINARY_BLOB_CREDENTIAL_INFO; 178 179 #define CRED_MAX_STRING_LENGTH 256 180 #define CRED_MAX_USERNAME_LENGTH 513 181 #define CRED_MAX_GENERIC_TARGET_NAME_LENGTH 32767 182 #define CRED_MAX_DOMAIN_TARGET_NAME_LENGTH 337 183 #define CRED_MAX_VALUE_SIZE 256 184 #define CRED_MAX_ATTRIBUTES 64 185 186 #define CRED_MAX_BLOB_SIZE 512 187 #define CRED_MAX_CREDENTIAL_BLOB_SIZE (5 * CRED_MAX_BLOB_SIZE) 188 189 #define CREDUI_MAX_MESSAGE_LENGTH 32767 190 #define CREDUI_MAX_CAPTION_LENGTH 128 191 #define CREDUI_MAX_GENERIC_TARGET_LENGTH CRED_MAX_GENERIC_TARGET_NAME_LENGTH 192 #define CREDUI_MAX_DOMAIN_TARGET_LENGTH CRED_MAX_DOMAIN_TARGET_LENGTH 193 #define CREDUI_MAX_USERNAME_LENGTH CRED_MAX_USERNAME_LENGTH 194 #define CREDUI_MAX_PASSWORD_LENGTH (CRED_MAX_CREDENTIAL_BLOB_SIZE / 2) 195 196 /* flags for CREDENTIAL::Flags */ 197 #define CRED_FLAGS_PASSWORD_FOR_CERT 0x0001 198 #define CRED_FLAGS_PROMPT_NOW 0x0002 199 #define CRED_FLAGS_USERNAME_TARGET 0x0004 200 #define CRED_FLAGS_OWF_CRED_BLOB 0x0008 201 #define CRED_FLAGS_VALID_FLAGS 0x000f 202 203 /* values for CREDENTIAL::Type */ 204 #define CRED_TYPE_GENERIC 1 205 #define CRED_TYPE_DOMAIN_PASSWORD 2 206 #define CRED_TYPE_DOMAIN_CERTIFICATE 3 207 #define CRED_TYPE_DOMAIN_VISIBLE_PASSWORD 4 208 #define CRED_TYPE_GENERIC_CERTIFICATE 5 209 #define CRED_TYPE_MAXIMUM 6 210 #define CRED_TYPE_MAXIMUM_EX (CRED_TYPE_MAXIMUM+1000) 211 212 /* values for CREDENTIAL::Persist */ 213 #define CRED_PERSIST_NONE 0 214 #define CRED_PERSIST_SESSION 1 215 #define CRED_PERSIST_LOCAL_MACHINE 2 216 #define CRED_PERSIST_ENTERPRISE 3 217 218 /* values for CREDENTIAL_TARGET_INFORMATION::Flags */ 219 #define CRED_TI_SERVER_FORMAT_UNKNOWN 1 220 #define CRED_TI_DOMAIN_FORMAT_UNKNOWN 2 221 #define CRED_TI_ONLY_PASSWORD_REQUIRED 4 222 223 #define CREDUI_FLAGS_INCORRECT_PASSWORD 0x00000001 224 #define CREDUI_FLAGS_DO_NOT_PERSIST 0x00000002 225 #define CREDUI_FLAGS_REQUEST_ADMINISTRATOR 0x00000004 226 #define CREDUI_FLAGS_EXCLUDE_CERTIFICATES 0x00000008 227 #define CREDUI_FLAGS_REQUIRE_CERTIFICATE 0x00000010 228 #define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX 0x00000040 229 #define CREDUI_FLAGS_ALWAYS_SHOW_UI 0x00000080 230 #define CREDUI_FLAGS_REQUIRE_SMARTCARD 0x00000100 231 #define CREDUI_FLAGS_PASSWORD_ONLY_OK 0x00000200 232 #define CREDUI_FLAGS_VALIDATE_USERNAME 0x00000400 233 #define CREDUI_FLAGS_COMPLETE_USERNAME 0x00000800 234 #define CREDUI_FLAGS_PERSIST 0x00001000 235 #define CREDUI_FLAGS_SERVER_CREDENTIAL 0x00004000 236 #define CREDUI_FLAGS_EXPECT_CONFIRMATION 0x00020000 237 #define CREDUI_FLAGS_GENERIC_CREDENTIALS 0x00040000 238 #define CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS 0x00080000 239 #define CREDUI_FLAGS_KEEP_USERNAME 0x00100000 240 241 /* flags for CredWrite and CredWriteDomainCredentials */ 242 #define CRED_PRESERVE_CREDENTIAL_BLOB 0x00000001 243 244 WINADVAPI BOOL WINAPI CredDeleteA(_In_ LPCSTR, _In_ DWORD, _Reserved_ DWORD); 245 WINADVAPI BOOL WINAPI CredDeleteW(_In_ LPCWSTR, _In_ DWORD, _Reserved_ DWORD); 246 #define CredDelete WINELIB_NAME_AW(CredDelete) 247 248 WINADVAPI 249 BOOL 250 WINAPI 251 CredEnumerateA( 252 _In_opt_ LPCSTR, 253 _Reserved_ DWORD, 254 _Out_ DWORD *Count, 255 _Outptr_result_buffer_(*Count) PCREDENTIALA **); 256 257 WINADVAPI 258 BOOL 259 WINAPI 260 CredEnumerateW( 261 _In_opt_ LPCWSTR, 262 _Reserved_ DWORD, 263 _Out_ DWORD *Count, 264 _Outptr_result_buffer_(*Count) PCREDENTIALW **); 265 266 #define CredEnumerate WINELIB_NAME_AW(CredEnumerate) 267 268 WINADVAPI VOID WINAPI CredFree(_In_ PVOID); 269 270 WINADVAPI 271 BOOL 272 WINAPI 273 CredGetSessionTypes( 274 _In_ DWORD MaximumPersistCount, 275 _Out_writes_(MaximumPersistCount) LPDWORD); 276 277 WINADVAPI BOOL WINAPI CredIsMarshaledCredentialA(_In_ LPCSTR); 278 WINADVAPI BOOL WINAPI CredIsMarshaledCredentialW(_In_ LPCWSTR); 279 #define CredIsMarshaledCredential WINELIB_NAME_AW(CredIsMarshaledCredential) 280 281 WINADVAPI 282 BOOL 283 WINAPI 284 CredMarshalCredentialA( 285 _In_ CRED_MARSHAL_TYPE, 286 _In_ PVOID, 287 _Out_ LPSTR *); 288 289 WINADVAPI 290 BOOL 291 WINAPI 292 CredMarshalCredentialW( 293 _In_ CRED_MARSHAL_TYPE, 294 _In_ PVOID, 295 _Out_ LPWSTR *); 296 297 #define CredMarshalCredential WINELIB_NAME_AW(CredMarshalCredential) 298 299 WINADVAPI 300 BOOL 301 WINAPI 302 CredReadA( 303 _In_ LPCSTR, 304 _In_ DWORD, 305 _Reserved_ DWORD, 306 _Out_ PCREDENTIALA *); 307 308 WINADVAPI 309 BOOL 310 WINAPI 311 CredReadW( 312 _In_ LPCWSTR, 313 _In_ DWORD, 314 _Reserved_ DWORD, 315 _Out_ PCREDENTIALW *); 316 317 #define CredRead WINELIB_NAME_AW(CredRead) 318 319 WINADVAPI 320 BOOL 321 WINAPI 322 CredReadDomainCredentialsA( 323 _In_ PCREDENTIAL_TARGET_INFORMATIONA, 324 _In_ DWORD, 325 _Out_ DWORD *Count, 326 _Outptr_result_buffer_(*Count) PCREDENTIALA **); 327 328 WINADVAPI 329 BOOL 330 WINAPI 331 CredReadDomainCredentialsW( 332 _In_ PCREDENTIAL_TARGET_INFORMATIONW, 333 _In_ DWORD, 334 _Out_ DWORD *Count, 335 _Outptr_result_buffer_(*Count) PCREDENTIALW **); 336 337 #define CredReadDomainCredentials WINELIB_NAME_AW(CredReadDomainCredentials) 338 339 WINADVAPI 340 BOOL 341 WINAPI 342 CredRenameA( 343 _In_ LPCSTR, 344 _In_ LPCSTR, 345 _In_ DWORD, 346 _Reserved_ DWORD); 347 348 WINADVAPI 349 BOOL 350 WINAPI 351 CredRenameW( 352 _In_ LPCWSTR, 353 _In_ LPCWSTR, 354 _In_ DWORD, 355 _Reserved_ DWORD); 356 357 #define CredRename WINELIB_NAME_AW(CredRename) 358 359 WINADVAPI 360 BOOL 361 WINAPI 362 CredUnmarshalCredentialA( 363 _In_ LPCSTR, 364 _Out_ PCRED_MARSHAL_TYPE, 365 _Out_ PVOID *); 366 367 WINADVAPI 368 BOOL 369 WINAPI 370 CredUnmarshalCredentialW( 371 _In_ LPCWSTR, 372 _Out_ PCRED_MARSHAL_TYPE, 373 _Out_ PVOID *); 374 375 #define CredUnmarshalCredential WINELIB_NAME_AW(CredUnmarshalCredential) 376 377 WINADVAPI BOOL WINAPI CredWriteA(_In_ PCREDENTIALA, _In_ DWORD); 378 WINADVAPI BOOL WINAPI CredWriteW(_In_ PCREDENTIALW, _In_ DWORD); 379 #define CredWrite WINELIB_NAME_AW(CredWrite) 380 381 DWORD 382 WINAPI 383 CredUICmdLinePromptForCredentialsW( 384 _In_opt_ PCWSTR, 385 _Reserved_ PCtxtHandle, 386 _In_ DWORD, 387 _Inout_updates_(ulUserBufferSize) PWSTR, 388 _In_ ULONG ulUserBufferSize, 389 _Inout_updates_(ulPasswordBufferSize) PWSTR, 390 _In_ ULONG ulPasswordBufferSize, 391 _Inout_opt_ PBOOL, 392 _In_ DWORD); 393 394 DWORD 395 WINAPI 396 CredUICmdLinePromptForCredentialsA( 397 _In_opt_ PCSTR, 398 _Reserved_ PCtxtHandle, 399 _In_ DWORD, 400 _Inout_updates_(ulUserBufferSize) PSTR, 401 _In_ ULONG ulUserBufferSize, 402 _Inout_updates_(ulPasswordBufferSize) PSTR, 403 _In_ ULONG ulPasswordBufferSize, 404 _Inout_opt_ PBOOL, 405 _In_ DWORD); 406 407 #define CredUICmdLinePromptForCredentials WINELIB_NAME_AW(CredUICmdLinePromptForCredentials) 408 409 DWORD WINAPI CredUIConfirmCredentialsW(_In_ PCWSTR, _In_ BOOL); 410 DWORD WINAPI CredUIConfirmCredentialsA(_In_ PCSTR, _In_ BOOL); 411 #define CredUIConfirmCredentials WINELIB_NAME_AW(CredUIConfirmCredentials) 412 413 DWORD 414 WINAPI 415 CredUIParseUserNameW( 416 _In_ PCWSTR, 417 _Out_writes_(userBufferSize) PWSTR, 418 _In_ ULONG userBufferSize, 419 _Out_writes_(domainBufferSize) PWSTR, 420 _In_ ULONG domainBufferSize); 421 422 DWORD 423 WINAPI 424 CredUIParseUserNameA( 425 _In_ PCSTR, 426 _Out_writes_(userBufferSize) PSTR, 427 _In_ ULONG userBufferSize, 428 _Out_writes_(domainBufferSize) PSTR, 429 _In_ ULONG domainBufferSize); 430 431 #define CredUIParseUserName WINELIB_NAME_AW(CredUIParseUserName) 432 433 DWORD 434 WINAPI 435 CredUIPromptForCredentialsW( 436 _In_opt_ PCREDUI_INFOW, 437 _In_opt_ PCWSTR, 438 _Reserved_ PCtxtHandle, 439 _In_ DWORD, 440 _Inout_updates_(ulUserNameBufferSize) PWSTR, 441 _In_ ULONG ulUserNameBufferSize, 442 _Inout_updates_(ulPasswordBufferSize) PWSTR, 443 _In_ ULONG ulPasswordBufferSize, 444 _Inout_opt_ PBOOL, 445 _In_ DWORD); 446 447 DWORD 448 WINAPI 449 CredUIPromptForCredentialsA( 450 _In_opt_ PCREDUI_INFOA, 451 _In_opt_ PCSTR, 452 _Reserved_ PCtxtHandle, 453 _In_ DWORD, 454 _Inout_updates_(ulUserNameBufferSize) PSTR, 455 _In_ ULONG ulUserNameBufferSize, 456 _Inout_updates_(ulPasswordBufferSize) PSTR, 457 _In_ ULONG ulPasswordBufferSize, 458 _Inout_opt_ PBOOL, 459 _In_ DWORD); 460 461 #define CredUIPromptForCredentials WINELIB_NAME_AW(CredUIPromptForCredentials) 462 463 DWORD 464 WINAPI 465 CredUIStoreSSOCredW( 466 _In_opt_ PCWSTR, 467 _In_ PCWSTR, 468 _In_ PCWSTR, 469 _In_ BOOL); 470 471 /* Note: no CredUIStoreSSOCredA in PSDK header */ 472 DWORD WINAPI CredUIReadSSOCredW(_In_opt_ PCWSTR, _Outptr_ PWSTR*); 473 /* Note: no CredUIReadSSOCredA in PSDK header */ 474 475 #ifdef __cplusplus 476 } 477 #endif 478 479 #endif /* _WINCRED_H_ */ 480