ReactOS 0.4.17-dev-806-gffa4164
credui_main.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnt.h"
#include "winuser.h"
#include "wincred.h"
#include "rpc.h"
#include "sspi.h"
#include "commctrl.h"
#include "credui_resources.h"
#include "wine/debug.h"
#include "wine/list.h"
Include dependency graph for credui_main.c:

Go to the source code of this file.

Classes

struct  pending_credentials
 
struct  cred_dialog_params
 

Macros

#define TOOLID_INCORRECTPASSWORD   1
 
#define TOOLID_CAPSLOCKON   2
 
#define ID_CAPSLOCKPOP   1
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (credui)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 
static DWORD save_credentials (PCWSTR pszTargetName, PCWSTR pszUsername, PCWSTR pszPassword, BOOL generic)
 
static void CredDialogFillUsernameCombo (HWND hwndUsername, const struct cred_dialog_params *params)
 
static void CredDialogCreateBalloonTip (HWND hwndDlg, struct cred_dialog_params *params)
 
static void CredDialogShowIncorrectPasswordBalloon (HWND hwndDlg, struct cred_dialog_params *params)
 
static void CredDialogShowCapsLockBalloon (HWND hwndDlg, struct cred_dialog_params *params)
 
static void CredDialogHideBalloonTip (HWND hwndDlg, struct cred_dialog_params *params)
 
static BOOL CredDialogCapsLockOn (void)
 
static LRESULT CALLBACK CredDialogPasswordSubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
 
static BOOL CredDialogInit (HWND hwndDlg, struct cred_dialog_params *params)
 
static void CredDialogCommandOk (HWND hwndDlg, struct cred_dialog_params *params)
 
static INT_PTR CALLBACK CredDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL find_existing_credential (const WCHAR *target, WCHAR *username, ULONG len_username, WCHAR *password, ULONG len_password)
 
DWORD WINAPI CredUIPromptForCredentialsW (PCREDUI_INFOW pUIInfo, PCWSTR pszTargetName, PCtxtHandle Reserved, DWORD dwAuthError, PWSTR pszUsername, ULONG ulUsernameMaxChars, PWSTR pszPassword, ULONG ulPasswordMaxChars, PBOOL pfSave, DWORD dwFlags)
 
DWORD WINAPI CredUIConfirmCredentialsW (PCWSTR pszTargetName, BOOL bConfirm)
 
DWORD WINAPI CredUIParseUserNameW (PCWSTR pszUserName, PWSTR pszUser, ULONG ulMaxUserChars, PWSTR pszDomain, ULONG ulMaxDomainChars)
 
DWORD WINAPI CredUIStoreSSOCredA (PCSTR pszRealm, PCSTR pszUsername, PCSTR pszPassword, BOOL bPersist)
 
DWORD WINAPI CredUIStoreSSOCredW (PCWSTR pszRealm, PCWSTR pszUsername, PCWSTR pszPassword, BOOL bPersist)
 
DWORD WINAPI CredUIReadSSOCredA (PCSTR pszRealm, PSTR *ppszUsername)
 
DWORD WINAPI CredUIReadSSOCredW (PCWSTR pszRealm, PWSTR *ppszUsername)
 
BOOL WINAPI CredUIInitControls (void)
 
ULONG SEC_ENTRY SspiPromptForCredentialsW (PCWSTR target, void *info, DWORD error, PCWSTR package, PSEC_WINNT_AUTH_IDENTITY_OPAQUE input_id, PSEC_WINNT_AUTH_IDENTITY_OPAQUE *output_id, BOOL *save, DWORD sspi_flags)
 
DWORD WINAPI CredUIPromptForWindowsCredentialsW (CREDUI_INFOW *info, DWORD error, ULONG *package, const void *in_buf, ULONG in_buf_size, void **out_buf, ULONG *out_buf_size, BOOL *save, DWORD flags)
 
BOOL WINAPI CredPackAuthenticationBufferW (DWORD flags, WCHAR *username, WCHAR *password, BYTE *buf, DWORD *size)
 
BOOL WINAPI CredUnPackAuthenticationBufferW (DWORD flags, void *buf, DWORD size, WCHAR *username, DWORD *len_username, WCHAR *domain, DWORD *len_domain, WCHAR *password, DWORD *len_password)
 

Variables

static HINSTANCE hinstCredUI
 
static struct list pending_credentials_list = LIST_INIT(pending_credentials_list)
 
static CRITICAL_SECTION csPendingCredentials = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 

Macro Definition Documentation

◆ ID_CAPSLOCKPOP

#define ID_CAPSLOCKPOP   1

Definition at line 42 of file credui_main.c.

◆ TOOLID_CAPSLOCKON

#define TOOLID_CAPSLOCKON   2

Definition at line 40 of file credui_main.c.

◆ TOOLID_INCORRECTPASSWORD

#define TOOLID_INCORRECTPASSWORD   1

Definition at line 39 of file credui_main.c.

Function Documentation

◆ CredDialogCapsLockOn()

static BOOL CredDialogCapsLockOn ( void  )
inlinestatic

Definition at line 344 of file credui_main.c.

345{
346 return (GetKeyState(VK_CAPITAL) & 0x1) != 0;
347}
#define VK_CAPITAL
Definition: winuser.h:2242
SHORT WINAPI GetKeyState(_In_ int)

Referenced by CredDialogInit(), CredDialogPasswordSubclassProc(), and CredDialogProc().

◆ CredDialogCommandOk()

static void CredDialogCommandOk ( HWND  hwndDlg,
struct cred_dialog_params params 
)
static

Definition at line 437 of file credui_main.c.

438{
439 HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME);
440 LPWSTR user;
441 INT len;
442 INT len2;
443
444 len = GetWindowTextLengthW(hwndUsername);
445 user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
446 GetWindowTextW(hwndUsername, user, len + 1);
447
448 if (!user[0])
449 {
451 return;
452 }
453
454 if (!wcschr(user, '\\') && !wcschr(user, '@'))
455 {
456 ULONG len_target = lstrlenW(params->pszTargetName);
457 memcpy(params->pszUsername, params->pszTargetName,
458 min(len_target, params->ulUsernameMaxChars) * sizeof(WCHAR));
459 if (len_target + 1 < params->ulUsernameMaxChars)
460 params->pszUsername[len_target] = '\\';
461 if (len_target + 2 < params->ulUsernameMaxChars)
462 params->pszUsername[len_target + 1] = '\0';
463 }
464 else if (params->ulUsernameMaxChars > 0)
465 params->pszUsername[0] = '\0';
466
467 len2 = lstrlenW(params->pszUsername);
468 memcpy(params->pszUsername + len2, user, min(len, params->ulUsernameMaxChars - len2) * sizeof(WCHAR));
469 if (params->ulUsernameMaxChars)
470 params->pszUsername[len2 + min(len, params->ulUsernameMaxChars - len2 - 1)] = '\0';
471
473
474 GetDlgItemTextW(hwndDlg, IDC_PASSWORD, params->pszPassword,
475 params->ulPasswordMaxChars);
476
477 params->fSave = IsDlgButtonChecked(hwndDlg, IDC_SAVE) == BST_CHECKED;
478
479 EndDialog(hwndDlg, IDOK);
480}
#define IDC_SAVE
Definition: resource.h:16
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define IDC_USERNAME
Definition: resource.h:82
#define IDC_PASSWORD
Definition: resource.h:20
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrlenW
Definition: compat.h:750
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum GLsizei len
Definition: glext.h:6722
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
short WCHAR
Definition: pedump.c:58
uint16_t * LPWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2283
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define BST_CHECKED
Definition: winuser.h:197
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by CredDialogProc().

◆ CredDialogCreateBalloonTip()

static void CredDialogCreateBalloonTip ( HWND  hwndDlg,
struct cred_dialog_params params 
)
static

Definition at line 197 of file credui_main.c.

198{
199 TTTOOLINFOW toolinfo;
200 WCHAR wszText[256];
201
202 if (params->hwndBalloonTip)
203 return;
204
209 SetWindowPos(params->hwndBalloonTip, HWND_TOPMOST, 0, 0, 0, 0,
211
213 {
214 ERR("failed to load IDS_INCORRECTPASSWORD\n");
215 return;
216 }
217
218 toolinfo.cbSize = sizeof(toolinfo);
219 toolinfo.uFlags = TTF_TRACK;
220 toolinfo.hwnd = hwndDlg;
221 toolinfo.uId = TOOLID_INCORRECTPASSWORD;
222 SetRectEmpty(&toolinfo.rect);
223 toolinfo.hinst = NULL;
224 toolinfo.lpszText = wszText;
225 toolinfo.lParam = 0;
226 toolinfo.lpReserved = NULL;
227 SendMessageW(params->hwndBalloonTip, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
228
229 if (!LoadStringW(hinstCredUI, IDS_CAPSLOCKON, wszText, ARRAY_SIZE(wszText)))
230 {
231 ERR("failed to load IDS_CAPSLOCKON\n");
232 return;
233 }
234
235 toolinfo.uId = TOOLID_CAPSLOCKON;
236 SendMessageW(params->hwndBalloonTip, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
237}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define ERR(fmt,...)
Definition: precomp.h:57
#define TOOLID_CAPSLOCKON
Definition: credui_main.c:40
#define TOOLID_INCORRECTPASSWORD
Definition: credui_main.c:39
static HINSTANCE hinstCredUI
Definition: credui_main.c:53
#define IDS_INCORRECTPASSWORD
#define IDS_CAPSLOCKON
#define NULL
Definition: types.h:112
LONG_PTR LPARAM
Definition: minwindef.h:175
#define WS_POPUP
Definition: pedump.c:616
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1707
#define TTM_ADDTOOLW
Definition: commctrl.h:1792
#define TTS_NOPREFIX
Definition: commctrl.h:1758
#define TTF_TRACK
Definition: commctrl.h:1768
#define TTS_BALLOON
Definition: commctrl.h:1761
#define LoadStringW
Definition: utils.h:64
HINSTANCE hinst
Definition: commctrl.h:1745
UINT_PTR uId
Definition: commctrl.h:1743
LPARAM lParam
Definition: commctrl.h:1747
LPWSTR lpszText
Definition: commctrl.h:1746
void * lpReserved
Definition: commctrl.h:1748
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define HWND_TOPMOST
Definition: winuser.h:1219
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1255
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define SWP_NOSIZE
Definition: winuser.h:1256
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define CW_USEDEFAULT
Definition: winuser.h:225
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by CredDialogShowCapsLockBalloon(), and CredDialogShowIncorrectPasswordBalloon().

◆ CredDialogFillUsernameCombo()

static void CredDialogFillUsernameCombo ( HWND  hwndUsername,
const struct cred_dialog_params params 
)
static

Definition at line 144 of file credui_main.c.

145{
146 DWORD count;
147 DWORD i;
148 PCREDENTIALW *credentials;
149
150 if (!CredEnumerateW(NULL, 0, &count, &credentials))
151 return;
152
153 for (i = 0; i < count; i++)
154 {
155 COMBOBOXEXITEMW comboitem;
156 DWORD j;
157 BOOL duplicate = FALSE;
158
159 if (!credentials[i]->UserName)
160 continue;
161
163 {
164 if (credentials[i]->Type != CRED_TYPE_GENERIC)
165 {
166 credentials[i]->UserName = NULL;
167 continue;
168 }
169 }
170 else if (credentials[i]->Type == CRED_TYPE_GENERIC)
171 {
172 credentials[i]->UserName = NULL;
173 continue;
174 }
175
176 /* don't add another item with the same name if we've already added it */
177 for (j = 0; j < i; j++)
178 if (credentials[j]->UserName
179 && !lstrcmpW(credentials[i]->UserName, credentials[j]->UserName))
180 {
181 duplicate = TRUE;
182 break;
183 }
184
185 if (duplicate)
186 continue;
187
188 comboitem.mask = CBEIF_TEXT;
189 comboitem.iItem = -1;
190 comboitem.pszText = credentials[i]->UserName;
191 SendMessageW(hwndUsername, CBEM_INSERTITEMW, 0, (LPARAM)&comboitem);
192 }
193
194 CredFree(credentials);
195}
Type
Definition: Type.h:7
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID WINAPI CredFree(PVOID Buffer)
Definition: cred.c:1395
BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIALW **Credentials)
Definition: cred.c:1289
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define CBEIF_TEXT
Definition: commctrl.h:3791
#define CBEM_INSERTITEMW
Definition: commctrl.h:3846
LPWSTR UserName
Definition: wincred.h:95
#define CREDUI_FLAGS_GENERIC_CREDENTIALS
Definition: wincred.h:237
#define CRED_TYPE_GENERIC
Definition: wincred.h:204

Referenced by CredDialogInit().

◆ CredDialogHideBalloonTip()

static void CredDialogHideBalloonTip ( HWND  hwndDlg,
struct cred_dialog_params params 
)
static

Definition at line 325 of file credui_main.c.

326{
327 TTTOOLINFOW toolinfo;
328
329 if (!params->hwndBalloonTip)
330 return;
331
332 memset(&toolinfo, 0, sizeof(toolinfo));
333
334 toolinfo.cbSize = sizeof(toolinfo);
335 toolinfo.hwnd = hwndDlg;
336 toolinfo.uId = 0;
337 SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, FALSE, (LPARAM)&toolinfo);
338 toolinfo.uId = 1;
339 SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, FALSE, (LPARAM)&toolinfo);
340
341 params->fBalloonTipActive = FALSE;
342}
#define TTM_TRACKACTIVATE
Definition: commctrl.h:1817
#define memset(x, y, z)
Definition: compat.h:39

Referenced by CredDialogPasswordSubclassProc(), and CredDialogProc().

◆ CredDialogInit()

static BOOL CredDialogInit ( HWND  hwndDlg,
struct cred_dialog_params params 
)
static

Definition at line 372 of file credui_main.c.

373{
374 HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME);
375 HWND hwndPassword = GetDlgItem(hwndDlg, IDC_PASSWORD);
376
378
379 if (params->hbmBanner)
381 IMAGE_BITMAP, (LPARAM)params->hbmBanner);
382
383 if (params->pszMessageText)
384 SetDlgItemTextW(hwndDlg, IDC_MESSAGE, params->pszMessageText);
385 else
386 {
387 WCHAR format[256];
388 WCHAR message[256];
390 swprintf(message, ARRAY_SIZE(message), format, params->pszTargetName);
392 }
393 SetWindowTextW(hwndUsername, params->pszUsername);
394 SetWindowTextW(hwndPassword, params->pszPassword);
395
396 CredDialogFillUsernameCombo(hwndUsername, params);
397
398 if (params->pszUsername[0])
399 {
400 /* prevent showing a balloon tip here */
401 params->fBalloonTipActive = TRUE;
402 SetFocus(hwndPassword);
403 params->fBalloonTipActive = FALSE;
404 }
405 else
406 SetFocus(hwndUsername);
407
408 if (params->pszCaptionText)
409 SetWindowTextW(hwndDlg, params->pszCaptionText);
410 else
411 {
412 WCHAR format[256];
413 WCHAR title[256];
415 swprintf(title, ARRAY_SIZE(title), format, params->pszTargetName);
416 SetWindowTextW(hwndDlg, title);
417 }
418
419 if (params->dwFlags & CREDUI_FLAGS_PERSIST ||
423 else if (params->fSave)
425
426 /* setup subclassing for Caps Lock detection */
428
431 else if ((GetFocus() == hwndPassword) && CredDialogCapsLockOn())
433
434 return FALSE;
435}
BOOL WINAPI SetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIDSubclass, DWORD_PTR dwRef)
Definition: commctrl.c:1272
static void CredDialogFillUsernameCombo(HWND hwndUsername, const struct cred_dialog_params *params)
Definition: credui_main.c:144
static LRESULT CALLBACK CredDialogPasswordSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
Definition: credui_main.c:349
static void CredDialogShowIncorrectPasswordBalloon(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:239
static void CredDialogShowCapsLockBalloon(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:283
static BOOL CredDialogCapsLockOn(void)
Definition: credui_main.c:344
#define IDB_BANNER
#define IDS_MESSAGEFORMAT
#define IDS_TITLEFORMAT
#define IDC_MESSAGE
Definition: resource.h:31
#define swprintf
Definition: precomp.h:40
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
static char title[]
Definition: ps.c:92
Definition: format.c:58
Definition: tftpd.h:60
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define CREDUI_FLAGS_INCORRECT_PASSWORD
Definition: wincred.h:223
#define CREDUI_FLAGS_PERSIST
Definition: wincred.h:234
#define CREDUI_FLAGS_DO_NOT_PERSIST
Definition: wincred.h:224
#define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX
Definition: wincred.h:228
HWND WINAPI GetFocus(void)
Definition: window.c:1887
#define SW_HIDE
Definition: winuser.h:779
#define IMAGE_BITMAP
Definition: winuser.h:211
#define DWLP_USER
Definition: winuser.h:883
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define STM_SETIMAGE
Definition: winuser.h:2129
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define SetWindowLongPtrW
Definition: winuser.h:5512

Referenced by CredDialogProc().

◆ CredDialogPasswordSubclassProc()

static LRESULT CALLBACK CredDialogPasswordSubclassProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
UINT_PTR  uIdSubclass,
DWORD_PTR  dwRefData 
)
static

Definition at line 349 of file credui_main.c.

351{
353 switch (uMsg)
354 {
355 case WM_KEYDOWN:
356 if (wParam == VK_CAPITAL)
357 {
358 HWND hwndDlg = GetParent(hwnd);
361 else
363 }
364 break;
365 case WM_DESTROY:
367 break;
368 }
369 return DefSubclassProc(hwnd, uMsg, wParam, lParam);
370}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID)
Definition: commctrl.c:1401
LRESULT WINAPI DefSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: commctrl.c:1507
static void CredDialogHideBalloonTip(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:325
_In_ SUBCLASSPROC _In_ UINT_PTR uIdSubclass
Definition: commctrl.h:5074
_In_ SUBCLASSPROC _In_ UINT_PTR _In_ DWORD_PTR dwRefData
Definition: commctrl.h:5075
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HWND WINAPI GetParent(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1637
#define WM_KEYDOWN
Definition: winuser.h:1743

Referenced by CredDialogInit(), and CredDialogPasswordSubclassProc().

◆ CredDialogProc()

static INT_PTR CALLBACK CredDialogProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 482 of file credui_main.c.

484{
485 switch (uMsg)
486 {
487 case WM_INITDIALOG:
488 {
490
491 return CredDialogInit(hwndDlg, params);
492 }
493 case WM_COMMAND:
494 switch (wParam)
495 {
496 case MAKELONG(IDOK, BN_CLICKED):
497 {
498 struct cred_dialog_params *params =
500 CredDialogCommandOk(hwndDlg, params);
501 return TRUE;
502 }
504 EndDialog(hwndDlg, IDCANCEL);
505 return TRUE;
508 {
509 struct cred_dialog_params *params =
512 }
513 /* don't allow another window to steal focus while the
514 * user is typing their password */
515 LockSetForegroundWindow(LSFW_LOCK);
516 return TRUE;
518 {
519 struct cred_dialog_params *params =
521 /* the user is no longer typing their password, so allow
522 * other windows to become foreground ones */
523 LockSetForegroundWindow(LSFW_UNLOCK);
525 return TRUE;
526 }
528 {
529 struct cred_dialog_params *params =
532 return TRUE;
533 }
534 }
535 return FALSE;
536 case WM_TIMER:
537 if (wParam == ID_CAPSLOCKPOP)
538 {
539 struct cred_dialog_params *params =
542 return TRUE;
543 }
544 return FALSE;
545 case WM_DESTROY:
546 {
547 struct cred_dialog_params *params =
549 if (params->hwndBalloonTip) DestroyWindow(params->hwndBalloonTip);
550 return TRUE;
551 }
552 default:
553 return FALSE;
554 }
555}
static void CredDialogCommandOk(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:437
#define ID_CAPSLOCKPOP
Definition: credui_main.c:42
static BOOL CredDialogInit(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:372
if(dx< 0)
Definition: linetemp.h:194
#define MAKELONG(a, b)
Definition: typedefs.h:249
BOOL WINAPI LockSetForegroundWindow(UINT uLockCode)
Definition: window.c:1639
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define EN_KILLFOCUS
Definition: winuser.h:2054
#define IDCANCEL
Definition: winuser.h:842
#define EN_SETFOCUS
Definition: winuser.h:2056
#define WM_COMMAND
Definition: winuser.h:1768
#define WM_INITDIALOG
Definition: winuser.h:1767
#define WM_TIMER
Definition: winuser.h:1770
#define BN_CLICKED
Definition: winuser.h:1954
BOOL WINAPI DestroyWindow(_In_ HWND)
#define EN_CHANGE
Definition: winuser.h:2051

Referenced by CredUIPromptForCredentialsW().

◆ CredDialogShowCapsLockBalloon()

static void CredDialogShowCapsLockBalloon ( HWND  hwndDlg,
struct cred_dialog_params params 
)
static

Definition at line 283 of file credui_main.c.

284{
285 TTTOOLINFOW toolinfo;
286 RECT rcPassword;
287 INT x;
288 INT y;
289 WCHAR wszTitle[256];
290
291 /* don't show two balloon tips at once */
292 if (params->fBalloonTipActive)
293 return;
294
295 if (!LoadStringW(hinstCredUI, IDS_CAPSLOCKONTITLE, wszTitle, ARRAY_SIZE(wszTitle)))
296 {
297 ERR("failed to load IDS_IDSCAPSLOCKONTITLE\n");
298 return;
299 }
300
302
303 memset(&toolinfo, 0, sizeof(toolinfo));
304 toolinfo.cbSize = sizeof(toolinfo);
305 toolinfo.hwnd = hwndDlg;
306 toolinfo.uId = TOOLID_CAPSLOCKON;
307
308 SendMessageW(params->hwndBalloonTip, TTM_SETTITLEW, TTI_WARNING, (LPARAM)wszTitle);
309
310 GetWindowRect(GetDlgItem(hwndDlg, IDC_PASSWORD), &rcPassword);
311 /* just inside the left side of the password edit control */
312 x = rcPassword.left + 12;
313 y = rcPassword.bottom - 3;
314 SendMessageW(params->hwndBalloonTip, TTM_TRACKPOSITION, 0, MAKELONG(x, y));
315
316 SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&toolinfo);
317
318 SetTimer(hwndDlg, ID_CAPSLOCKPOP,
319 SendMessageW(params->hwndBalloonTip, TTM_GETDELAYTIME, TTDT_AUTOPOP, 0),
320 NULL);
321
322 params->fBalloonTipActive = TRUE;
323}
static void CredDialogCreateBalloonTip(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:197
#define IDS_CAPSLOCKONTITLE
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define TTDT_AUTOPOP
Definition: commctrl.h:1776
#define TTM_GETDELAYTIME
Definition: commctrl.h:1821
#define TTM_SETTITLEW
Definition: commctrl.h:1833
#define TTM_TRACKPOSITION
Definition: commctrl.h:1818
#define TTI_WARNING
Definition: commctrl.h:1781
LONG bottom
Definition: windef.h:109
LONG left
Definition: windef.h:106
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)

Referenced by CredDialogInit(), CredDialogPasswordSubclassProc(), and CredDialogProc().

◆ CredDialogShowIncorrectPasswordBalloon()

static void CredDialogShowIncorrectPasswordBalloon ( HWND  hwndDlg,
struct cred_dialog_params params 
)
static

Definition at line 239 of file credui_main.c.

240{
241 TTTOOLINFOW toolinfo;
242 RECT rcPassword;
243 INT x;
244 INT y;
245 WCHAR wszTitle[256];
246
247 /* user name likely wrong so balloon would be confusing. focus is also
248 * not set to the password edit box, so more notification would need to be
249 * handled */
250 if (!params->pszUsername[0])
251 return;
252
253 /* don't show two balloon tips at once */
254 if (params->fBalloonTipActive)
255 return;
256
258 {
259 ERR("failed to load IDS_INCORRECTPASSWORDTITLE\n");
260 return;
261 }
262
264
265 memset(&toolinfo, 0, sizeof(toolinfo));
266 toolinfo.cbSize = sizeof(toolinfo);
267 toolinfo.hwnd = hwndDlg;
268 toolinfo.uId = TOOLID_INCORRECTPASSWORD;
269
270 SendMessageW(params->hwndBalloonTip, TTM_SETTITLEW, TTI_ERROR, (LPARAM)wszTitle);
271
272 GetWindowRect(GetDlgItem(hwndDlg, IDC_PASSWORD), &rcPassword);
273 /* centered vertically and in the right side of the password edit control */
274 x = rcPassword.right - 12;
275 y = (rcPassword.top + rcPassword.bottom) / 2;
276 SendMessageW(params->hwndBalloonTip, TTM_TRACKPOSITION, 0, MAKELONG(x, y));
277
278 SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&toolinfo);
279
280 params->fBalloonTipActive = TRUE;
281}
#define IDS_INCORRECTPASSWORDTITLE
#define TTI_ERROR
Definition: commctrl.h:1782
LONG right
Definition: windef.h:108
LONG top
Definition: windef.h:107

Referenced by CredDialogInit().

◆ CredPackAuthenticationBufferW()

BOOL WINAPI CredPackAuthenticationBufferW ( DWORD  flags,
WCHAR username,
WCHAR password,
BYTE buf,
DWORD size 
)

Definition at line 978 of file credui_main.c.

980{
981 FIXME( "(%08lx, %s, %p, %p, %p) stub\n", flags, debugstr_w(username), password, buf, size );
983}
#define FIXME(fmt,...)
Definition: precomp.h:53
static UCHAR password[]
Definition: bcrypt.c:520
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
#define debugstr_w
Definition: kernel32.h:32
static WCHAR username[]
Definition: url.c:32

◆ CredUIConfirmCredentialsW()

DWORD WINAPI CredUIConfirmCredentialsW ( PCWSTR  pszTargetName,
BOOL  bConfirm 
)

Definition at line 713 of file credui_main.c.

714{
717
718 TRACE("(%s, %s)\n", debugstr_w(pszTargetName), bConfirm ? "TRUE" : "FALSE");
719
720 if (!pszTargetName)
722
724
726 {
727 if (!lstrcmpW(pszTargetName, entry->pszTargetName))
728 {
729 if (bConfirm)
730 result = save_credentials(entry->pszTargetName, entry->pszUsername,
731 entry->pszPassword, entry->generic);
732 else
734
735 list_remove(&entry->entry);
736
737 HeapFree(GetProcessHeap(), 0, entry->pszTargetName);
738 HeapFree(GetProcessHeap(), 0, entry->pszUsername);
739 SecureZeroMemory(entry->pszPassword, lstrlenW(entry->pszPassword) * sizeof(WCHAR));
740 HeapFree(GetProcessHeap(), 0, entry->pszPassword);
742
743 break;
744 }
745 }
746
748
749 return result;
750}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static struct list pending_credentials_list
Definition: credui_main.c:55
static DWORD save_credentials(PCWSTR pszTargetName, PCWSTR pszUsername, PCWSTR pszPassword, BOOL generic)
Definition: credui_main.c:99
static CRITICAL_SECTION csPendingCredentials
Definition: credui_main.c:57
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
GLuint64EXT * result
Definition: glext.h:11304
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define TRACE(s)
Definition: solgame.cpp:4
#define SecureZeroMemory
Definition: winbase.h:1443
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define ERROR_NOT_FOUND
Definition: winerror.h:1014

Referenced by test_CredUIPromptForCredentials().

◆ CredUIInitControls()

BOOL WINAPI CredUIInitControls ( void  )

Definition at line 853 of file credui_main.c.

854{
855 FIXME("() stub\n");
856 return TRUE;
857}

◆ CredUIParseUserNameW()

DWORD WINAPI CredUIParseUserNameW ( PCWSTR  pszUserName,
PWSTR  pszUser,
ULONG  ulMaxUserChars,
PWSTR  pszDomain,
ULONG  ulMaxDomainChars 
)

Definition at line 755 of file credui_main.c.

758{
759 PWSTR p;
760
761 TRACE("(%s, %p, %ld, %p, %ld)\n", debugstr_w(pszUserName), pszUser,
762 ulMaxUserChars, pszDomain, ulMaxDomainChars);
763
764 if (!pszUserName || !pszUser || !ulMaxUserChars || !pszDomain ||
765 !ulMaxDomainChars)
767
768 /* FIXME: handle marshaled credentials */
769
770 p = wcschr(pszUserName, '\\');
771 if (p)
772 {
773 if (p - pszUserName > ulMaxDomainChars - 1)
775 if (lstrlenW(p + 1) > ulMaxUserChars - 1)
777 lstrcpyW(pszUser, p + 1);
778 memcpy(pszDomain, pszUserName, (p - pszUserName)*sizeof(WCHAR));
779 pszDomain[p - pszUserName] = '\0';
780
781 return ERROR_SUCCESS;
782 }
783
784 p = wcsrchr(pszUserName, '@');
785 if (p)
786 {
787 if (p + 1 - pszUserName > ulMaxUserChars - 1)
789 if (lstrlenW(p + 1) > ulMaxDomainChars - 1)
791 lstrcpyW(pszDomain, p + 1);
792 memcpy(pszUser, pszUserName, (p - pszUserName)*sizeof(WCHAR));
793 pszUser[p - pszUserName] = '\0';
794
795 return ERROR_SUCCESS;
796 }
797
798 if (lstrlenW(pszUserName) > ulMaxUserChars - 1)
800 lstrcpyW(pszUser, pszUserName);
801 pszDomain[0] = '\0';
802
803 return ERROR_SUCCESS;
804}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define wcsrchr
Definition: compat.h:16
#define lstrcpyW
Definition: compat.h:749
GLfloat GLfloat p
Definition: glext.h:8902
uint16_t * PWSTR
Definition: typedefs.h:56

◆ CredUIPromptForCredentialsW()

DWORD WINAPI CredUIPromptForCredentialsW ( PCREDUI_INFOW  pUIInfo,
PCWSTR  pszTargetName,
PCtxtHandle  Reserved,
DWORD  dwAuthError,
PWSTR  pszUsername,
ULONG  ulUsernameMaxChars,
PWSTR  pszPassword,
ULONG  ulPasswordMaxChars,
PBOOL  pfSave,
DWORD  dwFlags 
)

Definition at line 593 of file credui_main.c.

602{
603 INT_PTR ret;
606
607 TRACE("(%p, %s, %p, %ld, %s, %ld, %p, %ld, %p, 0x%08lx)\n", pUIInfo,
610
612 return ERROR_INVALID_FLAGS;
613
614 if (!pszTargetName)
616
617 if ((dwFlags & CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX) && !pfSave)
619
623 return ERROR_SUCCESS;
624
625 params.pszTargetName = pszTargetName;
626 if (pUIInfo)
627 {
628 params.pszMessageText = pUIInfo->pszMessageText;
629 params.pszCaptionText = pUIInfo->pszCaptionText;
630 params.hbmBanner = pUIInfo->hbmBanner;
631 }
632 else
633 {
634 params.pszMessageText = NULL;
635 params.pszCaptionText = NULL;
636 params.hbmBanner = NULL;
637 }
638 params.pszUsername = pszUsername;
639 params.ulUsernameMaxChars = ulUsernameMaxChars;
640 params.pszPassword = pszPassword;
641 params.ulPasswordMaxChars = ulPasswordMaxChars;
642 params.fSave = pfSave ? *pfSave : FALSE;
643 params.dwFlags = dwFlags;
644 params.hwndBalloonTip = NULL;
645 params.fBalloonTipActive = FALSE;
646
648 pUIInfo ? pUIInfo->hwndParent : NULL,
650 if (ret <= 0)
651 return GetLastError();
652
653 if (ret == IDCANCEL)
654 {
655 TRACE("dialog cancelled\n");
656 return ERROR_CANCELLED;
657 }
658
659 if (pfSave)
660 *pfSave = params.fSave;
661
662 if (params.fSave)
663 {
665 {
666 BOOL found = FALSE;
668 int len;
669
671
672 /* find existing pending credentials for the same target and overwrite */
673 /* FIXME: is this correct? */
675 if (!lstrcmpW(pszTargetName, entry->pszTargetName))
676 {
677 found = TRUE;
678 HeapFree(GetProcessHeap(), 0, entry->pszUsername);
679 SecureZeroMemory(entry->pszPassword, lstrlenW(entry->pszPassword) * sizeof(WCHAR));
680 HeapFree(GetProcessHeap(), 0, entry->pszPassword);
681 }
682
683 if (!found)
684 {
685 entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
687 entry->pszTargetName = HeapAlloc(GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR));
688 memcpy(entry->pszTargetName, pszTargetName, (len + 1)*sizeof(WCHAR));
690 }
691
692 len = lstrlenW(params.pszUsername);
693 entry->pszUsername = HeapAlloc(GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR));
694 memcpy(entry->pszUsername, params.pszUsername, (len + 1)*sizeof(WCHAR));
695 len = lstrlenW(params.pszPassword);
696 entry->pszPassword = HeapAlloc(GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR));
697 memcpy(entry->pszPassword, params.pszPassword, (len + 1)*sizeof(WCHAR));
699
701 }
705 }
706
707 return result;
708}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static BOOL find_existing_credential(const WCHAR *target, WCHAR *username, ULONG len_username, WCHAR *password, ULONG len_password)
Definition: credui_main.c:557
static INT_PTR CALLBACK CredDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: credui_main.c:482
#define IDD_CREDDIALOG
return ret
Definition: mutex.c:147
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
HWND hwndParent
Definition: wincred.h:144
PCWSTR pszMessageText
Definition: wincred.h:145
PCWSTR pszCaptionText
Definition: wincred.h:146
HBITMAP hbmBanner
Definition: wincred.h:147
int32_t INT_PTR
Definition: typedefs.h:64
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CREDUI_FLAGS_EXPECT_CONFIRMATION
Definition: wincred.h:236
#define CREDUI_FLAGS_ALWAYS_SHOW_UI
Definition: wincred.h:229
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
#define ERROR_CANCELLED
Definition: winerror.h:1055
#define ERROR_INVALID_FLAGS
Definition: winerror.h:907
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by SspiPromptForCredentialsW(), and test_CredUIPromptForCredentials().

◆ CredUIPromptForWindowsCredentialsW()

DWORD WINAPI CredUIPromptForWindowsCredentialsW ( CREDUI_INFOW info,
DWORD  error,
ULONG package,
const void in_buf,
ULONG  in_buf_size,
void **  out_buf,
ULONG out_buf_size,
BOOL save,
DWORD  flags 
)

Definition at line 966 of file credui_main.c.

969{
970 FIXME( "(%p, %lu, %p, %p, %lu, %p, %p, %p, %08lx) stub\n", info, error, package, in_buf, in_buf_size,
971 out_buf, out_buf_size, save, flags );
973}
#define error(str)
Definition: mkdosfs.c:1605

◆ CredUIReadSSOCredA()

DWORD WINAPI CredUIReadSSOCredA ( PCSTR  pszRealm,
PSTR ppszUsername 
)

Definition at line 831 of file credui_main.c.

832{
833 FIXME("(%s, %p)\n", debugstr_a(pszRealm), ppszUsername);
834 if (ppszUsername)
835 *ppszUsername = NULL;
836 return ERROR_NOT_FOUND;
837}
#define debugstr_a
Definition: kernel32.h:31

◆ CredUIReadSSOCredW()

DWORD WINAPI CredUIReadSSOCredW ( PCWSTR  pszRealm,
PWSTR ppszUsername 
)

Definition at line 842 of file credui_main.c.

843{
844 FIXME("(%s, %p)\n", debugstr_w(pszRealm), ppszUsername);
845 if (ppszUsername)
846 *ppszUsername = NULL;
847 return ERROR_NOT_FOUND;
848}

◆ CredUIStoreSSOCredA()

DWORD WINAPI CredUIStoreSSOCredA ( PCSTR  pszRealm,
PCSTR  pszUsername,
PCSTR  pszPassword,
BOOL  bPersist 
)

Definition at line 809 of file credui_main.c.

811{
812 FIXME("(%s, %s, %p, %d)\n", debugstr_a(pszRealm), debugstr_a(pszUsername),
813 pszPassword, bPersist);
814 return ERROR_SUCCESS;
815}

◆ CredUIStoreSSOCredW()

DWORD WINAPI CredUIStoreSSOCredW ( PCWSTR  pszRealm,
PCWSTR  pszUsername,
PCWSTR  pszPassword,
BOOL  bPersist 
)

Definition at line 820 of file credui_main.c.

822{
823 FIXME("(%s, %s, %p, %d)\n", debugstr_w(pszRealm), debugstr_w(pszUsername),
824 pszPassword, bPersist);
825 return ERROR_SUCCESS;
826}

◆ CredUnPackAuthenticationBufferW()

BOOL WINAPI CredUnPackAuthenticationBufferW ( DWORD  flags,
void buf,
DWORD  size,
WCHAR username,
DWORD len_username,
WCHAR domain,
DWORD len_domain,
WCHAR password,
DWORD len_password 
)

Definition at line 988 of file credui_main.c.

991{
992 FIXME( "(%08lx, %p, %lu, %p, %p, %p, %p, %p, %p) stub\n", flags, buf, size, username, len_username,
993 domain, len_domain, password, len_password );
995}
Definition: cookie.c:42

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 67 of file credui_main.c.

68{
69 struct pending_credentials *entry, *cursor2;
70 TRACE("(0x%p, %ld, %p)\n",hinstDLL,fdwReason,lpvReserved);
71
72 switch (fdwReason)
73 {
76 hinstCredUI = hinstDLL;
78 break;
79
81 if (lpvReserved) break;
83 {
84 list_remove(&entry->entry);
85
86 HeapFree(GetProcessHeap(), 0, entry->pszTargetName);
87 HeapFree(GetProcessHeap(), 0, entry->pszUsername);
88 SecureZeroMemory(entry->pszPassword, lstrlenW(entry->pszPassword) * sizeof(WCHAR));
89 HeapFree(GetProcessHeap(), 0, entry->pszPassword);
91 }
93 break;
94 }
95
96 return TRUE;
97}
static DWORD const fdwReason
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:874
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static IN DWORD IN LPVOID lpvReserved
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

◆ find_existing_credential()

static BOOL find_existing_credential ( const WCHAR target,
WCHAR username,
ULONG  len_username,
WCHAR password,
ULONG  len_password 
)
static

Definition at line 557 of file credui_main.c.

559{
560 DWORD count, i;
561 CREDENTIALW **credentials;
562
563 if (!CredEnumerateW(target, 0, &count, &credentials)) return FALSE;
564 for (i = 0; i < count; i++)
565 {
566 if (credentials[i]->Type != CRED_TYPE_DOMAIN_PASSWORD &&
567 credentials[i]->Type != CRED_TYPE_GENERIC)
568 {
569 FIXME("no support for type %lu credentials\n", credentials[i]->Type);
570 continue;
571 }
572 if ((!*username || !lstrcmpW(username, credentials[i]->UserName)) &&
573 lstrlenW(credentials[i]->UserName) < len_username &&
574 credentials[i]->CredentialBlobSize / sizeof(WCHAR) < len_password)
575 {
576 TRACE("found existing credential for %s\n", debugstr_w(credentials[i]->UserName));
577
578 lstrcpyW(username, credentials[i]->UserName);
579 memcpy(password, credentials[i]->CredentialBlob, credentials[i]->CredentialBlobSize);
580 password[credentials[i]->CredentialBlobSize / sizeof(WCHAR)] = 0;
581
582 CredFree(credentials);
583 return TRUE;
584 }
585 }
586 CredFree(credentials);
587 return FALSE;
588}
DWORD CredentialBlobSize
Definition: wincred.h:89
Definition: tools.h:99
#define CRED_TYPE_DOMAIN_PASSWORD
Definition: wincred.h:205

Referenced by CredUIPromptForCredentialsW(), and SspiPromptForCredentialsW().

◆ save_credentials()

static DWORD save_credentials ( PCWSTR  pszTargetName,
PCWSTR  pszUsername,
PCWSTR  pszPassword,
BOOL  generic 
)
static

Definition at line 99 of file credui_main.c.

101{
102 CREDENTIALW cred;
103
104 TRACE("saving servername %s with username %s\n", debugstr_w(pszTargetName), debugstr_w(pszUsername));
105
106 cred.Flags = 0;
108 cred.TargetName = (LPWSTR)pszTargetName;
109 cred.Comment = NULL;
110 cred.CredentialBlobSize = lstrlenW(pszPassword) * sizeof(WCHAR);
111 cred.CredentialBlob = (LPBYTE)pszPassword;
113 cred.AttributeCount = 0;
114 cred.Attributes = NULL;
115 cred.TargetAlias = NULL;
116 cred.UserName = (LPWSTR)pszUsername;
117
118 if (CredWriteW(&cred, 0))
119 return ERROR_SUCCESS;
120 else
121 {
123 ERR("CredWriteW failed with error %ld\n", ret);
124 return ret;
125 }
126}
BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags)
Definition: cred.c:1809
LPWSTR TargetName
Definition: wincred.h:86
LPBYTE CredentialBlob
Definition: wincred.h:90
DWORD AttributeCount
Definition: wincred.h:92
PCREDENTIAL_ATTRIBUTEW Attributes
Definition: wincred.h:93
DWORD Flags
Definition: wincred.h:84
DWORD Type
Definition: wincred.h:85
DWORD Persist
Definition: wincred.h:91
LPWSTR TargetAlias
Definition: wincred.h:94
LPWSTR Comment
Definition: wincred.h:87
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CRED_PERSIST_ENTERPRISE
Definition: wincred.h:216

Referenced by CredUIConfirmCredentialsW(), and CredUIPromptForCredentialsW().

◆ SspiPromptForCredentialsW()

ULONG SEC_ENTRY SspiPromptForCredentialsW ( PCWSTR  target,
void info,
DWORD  error,
PCWSTR  package,
PSEC_WINNT_AUTH_IDENTITY_OPAQUE  input_id,
PSEC_WINNT_AUTH_IDENTITY_OPAQUE output_id,
BOOL save,
DWORD  sspi_flags 
)

Definition at line 862 of file credui_main.c.

867{
870 DWORD len_username = ARRAY_SIZE(username);
871 DWORD len_password = ARRAY_SIZE(password);
872 DWORD ret, flags;
873 CREDUI_INFOW *cred_info = info;
874 SEC_WINNT_AUTH_IDENTITY_W *id = input_id;
875
876 FIXME( "(%s, %p, %lu, %s, %p, %p, %p, %lx) stub\n", debugstr_w(target), info,
877 error, debugstr_w(package), input_id, output_id, save, sspi_flags );
878
879 if (!target) return ERROR_INVALID_PARAMETER;
880 if (!package || (wcsicmp( package, L"Basic" ) && wcsicmp( package, L"NTLM" ) &&
881 wcsicmp( package, L"Negotiate" )))
882 {
883 FIXME( "package %s not supported\n", debugstr_w(package) );
885 }
886
888
889 if (sspi_flags & SSPIPFC_CREDPROV_DO_NOT_SAVE)
891
892 if (!(sspi_flags & SSPIPFC_NO_CHECKBOX))
894
895 if (!id) find_existing_credential( target, username, len_username, password, len_password );
896 else
897 {
898 if (id->User && id->UserLength > 0 && id->UserLength <= CREDUI_MAX_USERNAME_LENGTH)
899 {
900 memcpy( username, id->User, id->UserLength * sizeof(WCHAR) );
901 username[id->UserLength] = 0;
902 }
903 if (id->Password && id->PasswordLength > 0 && id->PasswordLength <= CREDUI_MAX_PASSWORD_LENGTH)
904 {
905 memcpy( password, id->Password, id->PasswordLength * sizeof(WCHAR) );
906 password[id->PasswordLength] = 0;
907 }
908 }
909
911 len_username, password, len_password, save, flags )))
912 {
913 DWORD size = sizeof(*id), len_domain = 0;
914 WCHAR *ptr, *user = username, *domain = NULL;
915
916 if ((ptr = wcschr( username, '\\' )))
917 {
918 user = ptr + 1;
919 len_username = lstrlenW( user );
920 if (!wcsicmp( package, L"NTLM" ) || !wcsicmp( package, L"Negotiate" ))
921 {
923 len_domain = ptr - username;
924 }
925 *ptr = 0;
926 }
927 else len_username = lstrlenW( username );
928 len_password = lstrlenW( password );
929
930 size += (len_username + 1) * sizeof(WCHAR);
931 size += (len_domain + 1) * sizeof(WCHAR);
932 size += (len_password + 1) * sizeof(WCHAR);
933 if (!(id = HeapAlloc( GetProcessHeap(), 0, size ))) return ERROR_OUTOFMEMORY;
934 ptr = (WCHAR *)(id + 1);
935
936 memcpy( ptr, user, (len_username + 1) * sizeof(WCHAR) );
937 id->User = ptr;
938 id->UserLength = len_username;
939 ptr += len_username + 1;
940 if (len_domain)
941 {
942 memcpy( ptr, domain, (len_domain + 1) * sizeof(WCHAR) );
943 id->Domain = ptr;
944 id->DomainLength = len_domain;
945 ptr += len_domain + 1;
946 }
947 else
948 {
949 id->Domain = NULL;
950 id->DomainLength = 0;
951 }
952 memcpy( ptr, password, (len_password + 1) * sizeof(WCHAR) );
953 id->Password = ptr;
954 id->PasswordLength = len_password;
955 id->Flags = 0;
956
957 *output_id = id;
958 }
959
960 return ret;
961}
DWORD WINAPI CredUIPromptForCredentialsW(PCREDUI_INFOW pUIInfo, PCWSTR pszTargetName, PCtxtHandle Reserved, DWORD dwAuthError, PWSTR pszUsername, ULONG ulUsernameMaxChars, PWSTR pszPassword, ULONG ulPasswordMaxChars, PBOOL pfSave, DWORD dwFlags)
Definition: credui_main.c:593
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define wcsicmp
Definition: compat.h:15
#define L(x)
Definition: resources.c:13
GLuint id
Definition: glext.h:5910
static PVOID ptr
Definition: dispmode.c:27
#define SSPIPFC_CREDPROV_DO_NOT_SAVE
Definition: sspi.h:93
#define SSPIPFC_NO_CHECKBOX
Definition: sspi.h:94
#define CREDUI_MAX_USERNAME_LENGTH
Definition: wincred.h:193
#define CREDUI_MAX_PASSWORD_LENGTH
Definition: wincred.h:194
#define ERROR_NO_SUCH_PACKAGE
Definition: winerror.h:1190

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( credui  )

Variable Documentation

◆ critsect_debug

CRITICAL_SECTION_DEBUG critsect_debug
static
Initial value:
=
{
0, 0, { (DWORD_PTR)(__FILE__ ": csPendingCredentials") }
}
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: credui_main.c:58
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 58 of file credui_main.c.

◆ csPendingCredentials

static CRITICAL_SECTION csPendingCredentials = { &critsect_debug, -1, 0, 0, 0, 0 }
static

Definition at line 57 of file credui_main.c.

Referenced by CredUIConfirmCredentialsW(), CredUIPromptForCredentialsW(), and DllMain().

◆ hinstCredUI

◆ pending_credentials_list

struct list pending_credentials_list = LIST_INIT(pending_credentials_list)
static

Definition at line 55 of file credui_main.c.

Referenced by CredUIConfirmCredentialsW(), CredUIPromptForCredentialsW(), and DllMain().