ReactOS  0.4.13-dev-241-g63286c6
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/unicode.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 43 of file credui_main.c.

◆ TOOLID_CAPSLOCKON

#define TOOLID_CAPSLOCKON   2

Definition at line 41 of file credui_main.c.

◆ TOOLID_INCORRECTPASSWORD

#define TOOLID_INCORRECTPASSWORD   1

Definition at line 40 of file credui_main.c.

Function Documentation

◆ CredDialogCapsLockOn()

static BOOL CredDialogCapsLockOn ( void  )
inlinestatic

Definition at line 348 of file credui_main.c.

349 {
350  return (GetKeyState(VK_CAPITAL) & 0x1) != 0;
351 }
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
SHORT WINAPI GetKeyState(_In_ int)
#define VK_CAPITAL
Definition: winuser.h:2160

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

◆ CredDialogCommandOk()

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

Definition at line 441 of file credui_main.c.

442 {
443  HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME);
444  LPWSTR user;
445  INT len;
446  INT len2;
447 
448  len = GetWindowTextLengthW(hwndUsername);
449  user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
450  GetWindowTextW(hwndUsername, user, len + 1);
451 
452  if (!user[0])
453  {
455  return;
456  }
457 
458  if (!strchrW(user, '\\') && !strchrW(user, '@'))
459  {
460  ULONG len_target = strlenW(params->pszTargetName);
461  memcpy(params->pszUsername, params->pszTargetName,
462  min(len_target, params->ulUsernameMaxChars) * sizeof(WCHAR));
463  if (len_target + 1 < params->ulUsernameMaxChars)
464  params->pszUsername[len_target] = '\\';
465  if (len_target + 2 < params->ulUsernameMaxChars)
466  params->pszUsername[len_target + 1] = '\0';
467  }
468  else if (params->ulUsernameMaxChars > 0)
469  params->pszUsername[0] = '\0';
470 
471  len2 = strlenW(params->pszUsername);
472  memcpy(params->pszUsername + len2, user, min(len, params->ulUsernameMaxChars - len2) * sizeof(WCHAR));
473  if (params->ulUsernameMaxChars)
474  params->pszUsername[len2 + min(len, params->ulUsernameMaxChars - len2 - 1)] = '\0';
475 
477 
478  GetDlgItemTextW(hwndDlg, IDC_PASSWORD, params->pszPassword,
479  params->ulPasswordMaxChars);
480 
481  params->fSave = IsDlgButtonChecked(hwndDlg, IDC_SAVE) == BST_CHECKED;
482 
483  EndDialog(hwndDlg, IDOK);
484 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2195
#define IDOK
Definition: winuser.h:824
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define IDC_SAVE
Definition: resource.h:16
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
GLenum const GLfloat * params
Definition: glext.h:5645
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define IDC_USERNAME
Definition: resource.h:77
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1378
#define min(a, b)
Definition: monoChain.cc:55
#define BST_CHECKED
Definition: winuser.h:197
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define HeapFree(x, y, z)
Definition: compat.h:394
#define IDC_PASSWORD
Definition: resource.h:12

Referenced by CredDialogProc().

◆ CredDialogCreateBalloonTip()

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

Definition at line 201 of file credui_main.c.

202 {
203  TTTOOLINFOW toolinfo;
204  WCHAR wszText[256];
205 
206  if (params->hwndBalloonTip)
207  return;
208 
212  hinstCredUI, NULL);
213  SetWindowPos(params->hwndBalloonTip, HWND_TOPMOST, 0, 0, 0, 0,
215 
216  if (!LoadStringW(hinstCredUI, IDS_INCORRECTPASSWORD, wszText, ARRAY_SIZE(wszText)))
217  {
218  ERR("failed to load IDS_INCORRECTPASSWORD\n");
219  return;
220  }
221 
222  toolinfo.cbSize = sizeof(toolinfo);
223  toolinfo.uFlags = TTF_TRACK;
224  toolinfo.hwnd = hwndDlg;
225  toolinfo.uId = TOOLID_INCORRECTPASSWORD;
226  SetRectEmpty(&toolinfo.rect);
227  toolinfo.hinst = NULL;
228  toolinfo.lpszText = wszText;
229  toolinfo.lParam = 0;
230  toolinfo.lpReserved = NULL;
231  SendMessageW(params->hwndBalloonTip, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
232 
233  if (!LoadStringW(hinstCredUI, IDS_CAPSLOCKON, wszText, ARRAY_SIZE(wszText)))
234  {
235  ERR("failed to load IDS_CAPSLOCKON\n");
236  return;
237  }
238 
239  toolinfo.uId = TOOLID_CAPSLOCKON;
240  SendMessageW(params->hwndBalloonTip, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
241 }
#define IDS_CAPSLOCKON
static HINSTANCE hinstCredUI
Definition: credui_main.c:54
#define HWND_TOPMOST
Definition: winuser.h:1194
#define TTS_BALLOON
Definition: commctrl.h:1733
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LPWSTR lpszText
Definition: commctrl.h:1718
GLenum const GLfloat * params
Definition: glext.h:5645
void * lpReserved
Definition: commctrl.h:1720
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TTF_TRACK
Definition: commctrl.h:1740
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SWP_NOACTIVATE
Definition: winuser.h:1227
UINT_PTR uId
Definition: commctrl.h:1715
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1679
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)
HINSTANCE hinst
Definition: commctrl.h:1717
#define IDS_INCORRECTPASSWORD
#define SWP_NOSIZE
Definition: winuser.h:1230
#define ERR(fmt,...)
Definition: debug.h:109
#define ARRAY_SIZE(a)
Definition: main.h:24
#define TTM_ADDTOOLW
Definition: commctrl.h:1759
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WS_POPUP
Definition: pedump.c:616
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define TOOLID_CAPSLOCKON
Definition: credui_main.c:41
#define TTS_NOPREFIX
Definition: commctrl.h:1730
LPARAM lParam
Definition: commctrl.h:1719
#define TOOLID_INCORRECTPASSWORD
Definition: credui_main.c:40

Referenced by CredDialogShowCapsLockBalloon(), and CredDialogShowIncorrectPasswordBalloon().

◆ CredDialogFillUsernameCombo()

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

Definition at line 148 of file credui_main.c.

149 {
150  DWORD count;
151  DWORD i;
152  PCREDENTIALW *credentials;
153 
154  if (!CredEnumerateW(NULL, 0, &count, &credentials))
155  return;
156 
157  for (i = 0; i < count; i++)
158  {
159  COMBOBOXEXITEMW comboitem;
160  DWORD j;
161  BOOL duplicate = FALSE;
162 
163  if (!credentials[i]->UserName)
164  continue;
165 
167  {
168  if (credentials[i]->Type != CRED_TYPE_GENERIC)
169  {
170  credentials[i]->UserName = NULL;
171  continue;
172  }
173  }
174  else if (credentials[i]->Type == CRED_TYPE_GENERIC)
175  {
176  credentials[i]->UserName = NULL;
177  continue;
178  }
179 
180  /* don't add another item with the same name if we've already added it */
181  for (j = 0; j < i; j++)
182  if (credentials[j]->UserName
183  && !strcmpW(credentials[i]->UserName, credentials[j]->UserName))
184  {
185  duplicate = TRUE;
186  break;
187  }
188 
189  if (duplicate)
190  continue;
191 
192  comboitem.mask = CBEIF_TEXT;
193  comboitem.iItem = -1;
194  comboitem.pszText = credentials[i]->UserName;
195  SendMessageW(hwndUsername, CBEM_INSERTITEMW, 0, (LPARAM)&comboitem);
196  }
197 
198  CredFree(credentials);
199 }
#define TRUE
Definition: types.h:120
Type
Definition: Type.h:6
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define CREDUI_FLAGS_GENERIC_CREDENTIALS
Definition: wincred.h:237
BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIALW **Credentials)
Definition: cred.c:1289
LPWSTR UserName
Definition: wincred.h:95
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
GLenum const GLfloat * params
Definition: glext.h:5645
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CBEIF_TEXT
Definition: commctrl.h:3758
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
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
VOID WINAPI CredFree(PVOID Buffer)
Definition: cred.c:1395
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CRED_TYPE_GENERIC
Definition: wincred.h:204
#define CBEM_INSERTITEMW
Definition: commctrl.h:3813
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229

Referenced by CredDialogInit().

◆ CredDialogHideBalloonTip()

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

Definition at line 329 of file credui_main.c.

330 {
331  TTTOOLINFOW toolinfo;
332 
333  if (!params->hwndBalloonTip)
334  return;
335 
336  memset(&toolinfo, 0, sizeof(toolinfo));
337 
338  toolinfo.cbSize = sizeof(toolinfo);
339  toolinfo.hwnd = hwndDlg;
340  toolinfo.uId = 0;
341  SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, FALSE, (LPARAM)&toolinfo);
342  toolinfo.uId = 1;
343  SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, FALSE, (LPARAM)&toolinfo);
344 
345  params->fBalloonTipActive = FALSE;
346 }
GLenum const GLfloat * params
Definition: glext.h:5645
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR uId
Definition: commctrl.h:1715
#define TTM_TRACKACTIVATE
Definition: commctrl.h:1784
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#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 376 of file credui_main.c.

377 {
378  HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME);
379  HWND hwndPassword = GetDlgItem(hwndDlg, IDC_PASSWORD);
380 
382 
383  if (params->hbmBanner)
385  IMAGE_BITMAP, (LPARAM)params->hbmBanner);
386 
387  if (params->pszMessageText)
388  SetDlgItemTextW(hwndDlg, IDC_MESSAGE, params->pszMessageText);
389  else
390  {
391  WCHAR format[256];
392  WCHAR message[256];
394  snprintfW(message, ARRAY_SIZE(message), format, params->pszTargetName);
396  }
397  SetWindowTextW(hwndUsername, params->pszUsername);
398  SetWindowTextW(hwndPassword, params->pszPassword);
399 
400  CredDialogFillUsernameCombo(hwndUsername, params);
401 
402  if (params->pszUsername[0])
403  {
404  /* prevent showing a balloon tip here */
405  params->fBalloonTipActive = TRUE;
406  SetFocus(hwndPassword);
407  params->fBalloonTipActive = FALSE;
408  }
409  else
410  SetFocus(hwndUsername);
411 
412  if (params->pszCaptionText)
413  SetWindowTextW(hwndDlg, params->pszCaptionText);
414  else
415  {
416  WCHAR format[256];
417  WCHAR title[256];
419  snprintfW(title, ARRAY_SIZE(title), format, params->pszTargetName);
420  SetWindowTextW(hwndDlg, title);
421  }
422 
423  if (params->dwFlags & CREDUI_FLAGS_PERSIST ||
424  (params->dwFlags & CREDUI_FLAGS_DO_NOT_PERSIST &&
427  else if (params->fSave)
429 
430  /* setup subclassing for Caps Lock detection */
432 
435  else if ((GetFocus() == hwndPassword) && CredDialogCapsLockOn())
437 
438  return FALSE;
439 }
static LRESULT CALLBACK CredDialogPasswordSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
Definition: credui_main.c:353
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define CREDUI_FLAGS_PERSIST
Definition: wincred.h:234
static void CredDialogShowCapsLockBalloon(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:287
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define snprintfW
Definition: unicode.h:60
#define IDS_MESSAGEFORMAT
static BOOL CredDialogCapsLockOn(void)
Definition: credui_main.c:348
#define SW_HIDE
Definition: winuser.h:762
#define IDB_BANNER
static HINSTANCE hinstCredUI
Definition: credui_main.c:54
static void CredDialogShowIncorrectPasswordBalloon(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:243
#define CREDUI_FLAGS_INCORRECT_PASSWORD
Definition: wincred.h:223
#define IDC_MESSAGE
Definition: resource.h:22
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDC_SAVE
Definition: resource.h:16
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define IDS_TITLEFORMAT
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define CREDUI_FLAGS_DO_NOT_PERSIST
Definition: wincred.h:224
GLenum const GLfloat * params
Definition: glext.h:5645
static void CredDialogFillUsernameCombo(HWND hwndUsername, const struct cred_dialog_params *params)
Definition: credui_main.c:148
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI SetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIDSubclass, DWORD_PTR dwRef)
Definition: commctrl.c:1261
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDC_USERNAME
Definition: resource.h:77
#define DWLP_USER
Definition: winuser.h:866
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define ARRAY_SIZE(a)
Definition: main.h:24
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IMAGE_BITMAP
Definition: winuser.h:211
#define STM_SETIMAGE
Definition: winuser.h:2054
#define BST_CHECKED
Definition: winuser.h:197
HWND WINAPI GetFocus(void)
Definition: window.c:1875
#define SetWindowLongPtrW
Definition: winuser.h:5215
static char title[]
Definition: ps.c:92
#define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX
Definition: wincred.h:228
#define IDC_PASSWORD
Definition: resource.h:12

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 353 of file credui_main.c.

355 {
357  switch (uMsg)
358  {
359  case WM_KEYDOWN:
360  if (wParam == VK_CAPITAL)
361  {
362  HWND hwndDlg = GetParent(hwnd);
363  if (CredDialogCapsLockOn())
365  else
367  }
368  break;
369  case WM_DESTROY:
371  break;
372  }
373  return DefSubclassProc(hwnd, uMsg, wParam, lParam);
374 }
static LRESULT CALLBACK CredDialogPasswordSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
Definition: credui_main.c:353
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static void CredDialogShowCapsLockBalloon(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:287
static BOOL CredDialogCapsLockOn(void)
Definition: credui_main.c:348
_In_ SUBCLASSPROC _In_ UINT_PTR _In_ DWORD_PTR dwRefData
Definition: commctrl.h:5027
static void CredDialogHideBalloonTip(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:329
WPARAM wParam
Definition: combotst.c:138
GLenum const GLfloat * params
Definition: glext.h:5645
#define WM_KEYDOWN
Definition: winuser.h:1691
LRESULT WINAPI DefSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: commctrl.c:1496
#define WM_DESTROY
Definition: winuser.h:1591
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID)
Definition: commctrl.c:1390
#define VK_CAPITAL
Definition: winuser.h:2160
LPARAM lParam
Definition: combotst.c:139
_In_ SUBCLASSPROC _In_ UINT_PTR uIdSubclass
Definition: commctrl.h:5027

Referenced by CredDialogInit().

◆ CredDialogProc()

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

Definition at line 486 of file credui_main.c.

488 {
489  switch (uMsg)
490  {
491  case WM_INITDIALOG:
492  {
494 
495  return CredDialogInit(hwndDlg, params);
496  }
497  case WM_COMMAND:
498  switch (wParam)
499  {
500  case MAKELONG(IDOK, BN_CLICKED):
501  {
502  struct cred_dialog_params *params =
503  (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
504  CredDialogCommandOk(hwndDlg, params);
505  return TRUE;
506  }
508  EndDialog(hwndDlg, IDCANCEL);
509  return TRUE;
512  {
513  struct cred_dialog_params *params =
514  (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
516  }
517  /* don't allow another window to steal focus while the
518  * user is typing their password */
519  LockSetForegroundWindow(LSFW_LOCK);
520  return TRUE;
522  {
523  struct cred_dialog_params *params =
524  (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
525  /* the user is no longer typing their password, so allow
526  * other windows to become foreground ones */
527  LockSetForegroundWindow(LSFW_UNLOCK);
529  return TRUE;
530  }
532  {
533  struct cred_dialog_params *params =
534  (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
536  return TRUE;
537  }
538  }
539  return FALSE;
540  case WM_TIMER:
541  if (wParam == ID_CAPSLOCKPOP)
542  {
543  struct cred_dialog_params *params =
544  (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
546  return TRUE;
547  }
548  return FALSE;
549  case WM_DESTROY:
550  {
551  struct cred_dialog_params *params =
552  (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
553  if (params->hwndBalloonTip) DestroyWindow(params->hwndBalloonTip);
554  return TRUE;
555  }
556  default:
557  return FALSE;
558  }
559 }
static void CredDialogShowCapsLockBalloon(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:287
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
static BOOL CredDialogCapsLockOn(void)
Definition: credui_main.c:348
#define GetWindowLongPtrW
Definition: winuser.h:4698
BOOL WINAPI DestroyWindow(_In_ HWND)
static void CredDialogHideBalloonTip(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:329
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define EN_KILLFOCUS
Definition: winuser.h:1986
#define EN_SETFOCUS
Definition: winuser.h:1988
GLenum const GLfloat * params
Definition: glext.h:5645
#define MAKELONG(a, b)
Definition: typedefs.h:248
BOOL WINAPI LockSetForegroundWindow(UINT uLockCode)
Definition: window.c:1612
#define WM_DESTROY
Definition: winuser.h:1591
static void CredDialogCommandOk(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:441
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define WM_TIMER
Definition: winuser.h:1718
#define BN_CLICKED
Definition: winuser.h:1886
#define ID_CAPSLOCKPOP
Definition: credui_main.c:43
static BOOL CredDialogInit(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:376
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1716
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define IDC_PASSWORD
Definition: resource.h:12
#define EN_CHANGE
Definition: winuser.h:1983

Referenced by CredUIPromptForCredentialsW().

◆ CredDialogShowCapsLockBalloon()

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

Definition at line 287 of file credui_main.c.

288 {
289  TTTOOLINFOW toolinfo;
290  RECT rcPassword;
291  INT x;
292  INT y;
293  WCHAR wszTitle[256];
294 
295  /* don't show two balloon tips at once */
296  if (params->fBalloonTipActive)
297  return;
298 
299  if (!LoadStringW(hinstCredUI, IDS_CAPSLOCKONTITLE, wszTitle, ARRAY_SIZE(wszTitle)))
300  {
301  ERR("failed to load IDS_IDSCAPSLOCKONTITLE\n");
302  return;
303  }
304 
306 
307  memset(&toolinfo, 0, sizeof(toolinfo));
308  toolinfo.cbSize = sizeof(toolinfo);
309  toolinfo.hwnd = hwndDlg;
310  toolinfo.uId = TOOLID_CAPSLOCKON;
311 
312  SendMessageW(params->hwndBalloonTip, TTM_SETTITLEW, TTI_WARNING, (LPARAM)wszTitle);
313 
314  GetWindowRect(GetDlgItem(hwndDlg, IDC_PASSWORD), &rcPassword);
315  /* just inside the left side of the password edit control */
316  x = rcPassword.left + 12;
317  y = rcPassword.bottom - 3;
318  SendMessageW(params->hwndBalloonTip, TTM_TRACKPOSITION, 0, MAKELONG(x, y));
319 
320  SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&toolinfo);
321 
322  SetTimer(hwndDlg, ID_CAPSLOCKPOP,
323  SendMessageW(params->hwndBalloonTip, TTM_GETDELAYTIME, TTDT_AUTOPOP, 0),
324  NULL);
325 
326  params->fBalloonTipActive = TRUE;
327 }
#define TTM_GETDELAYTIME
Definition: commctrl.h:1788
#define IDS_CAPSLOCKONTITLE
#define TRUE
Definition: types.h:120
static HINSTANCE hinstCredUI
Definition: credui_main.c:54
#define TTM_TRACKPOSITION
Definition: commctrl.h:1785
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG left
Definition: windef.h:291
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
static void CredDialogCreateBalloonTip(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:201
GLenum const GLfloat * params
Definition: glext.h:5645
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define TTM_SETTITLEW
Definition: commctrl.h:1800
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TTI_WARNING
Definition: commctrl.h:1753
UINT_PTR uId
Definition: commctrl.h:1715
#define ID_CAPSLOCKPOP
Definition: credui_main.c:43
#define ERR(fmt,...)
Definition: debug.h:109
#define TTM_TRACKACTIVATE
Definition: commctrl.h:1784
#define ARRAY_SIZE(a)
Definition: main.h:24
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define TOOLID_CAPSLOCKON
Definition: credui_main.c:41
#define memset(x, y, z)
Definition: compat.h:39
#define TTDT_AUTOPOP
Definition: commctrl.h:1748
#define IDC_PASSWORD
Definition: resource.h:12

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

◆ CredDialogShowIncorrectPasswordBalloon()

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

Definition at line 243 of file credui_main.c.

244 {
245  TTTOOLINFOW toolinfo;
246  RECT rcPassword;
247  INT x;
248  INT y;
249  WCHAR wszTitle[256];
250 
251  /* user name likely wrong so balloon would be confusing. focus is also
252  * not set to the password edit box, so more notification would need to be
253  * handled */
254  if (!params->pszUsername[0])
255  return;
256 
257  /* don't show two balloon tips at once */
258  if (params->fBalloonTipActive)
259  return;
260 
261  if (!LoadStringW(hinstCredUI, IDS_INCORRECTPASSWORDTITLE, wszTitle, ARRAY_SIZE(wszTitle)))
262  {
263  ERR("failed to load IDS_INCORRECTPASSWORDTITLE\n");
264  return;
265  }
266 
268 
269  memset(&toolinfo, 0, sizeof(toolinfo));
270  toolinfo.cbSize = sizeof(toolinfo);
271  toolinfo.hwnd = hwndDlg;
272  toolinfo.uId = TOOLID_INCORRECTPASSWORD;
273 
274  SendMessageW(params->hwndBalloonTip, TTM_SETTITLEW, TTI_ERROR, (LPARAM)wszTitle);
275 
276  GetWindowRect(GetDlgItem(hwndDlg, IDC_PASSWORD), &rcPassword);
277  /* centered vertically and in the right side of the password edit control */
278  x = rcPassword.right - 12;
279  y = (rcPassword.top + rcPassword.bottom) / 2;
280  SendMessageW(params->hwndBalloonTip, TTM_TRACKPOSITION, 0, MAKELONG(x, y));
281 
282  SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&toolinfo);
283 
284  params->fBalloonTipActive = TRUE;
285 }
#define TRUE
Definition: types.h:120
#define IDS_INCORRECTPASSWORDTITLE
static HINSTANCE hinstCredUI
Definition: credui_main.c:54
#define TTM_TRACKPOSITION
Definition: commctrl.h:1785
LONG top
Definition: windef.h:292
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG right
Definition: windef.h:293
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
static void CredDialogCreateBalloonTip(HWND hwndDlg, struct cred_dialog_params *params)
Definition: credui_main.c:201
GLenum const GLfloat * params
Definition: glext.h:5645
#define MAKELONG(a, b)
Definition: typedefs.h:248
LONG_PTR LPARAM
Definition: windef.h:208
#define TTM_SETTITLEW
Definition: commctrl.h:1800
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT_PTR uId
Definition: commctrl.h:1715
#define ERR(fmt,...)
Definition: debug.h:109
#define TTM_TRACKACTIVATE
Definition: commctrl.h:1784
#define ARRAY_SIZE(a)
Definition: main.h:24
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define TTI_ERROR
Definition: commctrl.h:1754
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define memset(x, y, z)
Definition: compat.h:39
#define IDC_PASSWORD
Definition: resource.h:12
#define TOOLID_INCORRECTPASSWORD
Definition: credui_main.c:40

Referenced by CredDialogInit().

◆ CredPackAuthenticationBufferW()

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

Definition at line 985 of file credui_main.c.

987 {
988  FIXME( "(%08x, %s, %p, %p, %p) stub\n", flags, debugstr_w(username), password, buf, size );
990 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
static WCHAR username[]
Definition: url.c:32
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ CredUIConfirmCredentialsW()

DWORD WINAPI CredUIConfirmCredentialsW ( PCWSTR  pszTargetName,
BOOL  bConfirm 
)

Definition at line 717 of file credui_main.c.

718 {
719  struct pending_credentials *entry;
721 
722  TRACE("(%s, %s)\n", debugstr_w(pszTargetName), bConfirm ? "TRUE" : "FALSE");
723 
724  if (!pszTargetName)
726 
728 
730  {
731  if (!strcmpW(pszTargetName, entry->pszTargetName))
732  {
733  if (bConfirm)
734  result = save_credentials(entry->pszTargetName, entry->pszUsername,
735  entry->pszPassword, entry->generic);
736  else
738 
739  list_remove(&entry->entry);
740 
741  HeapFree(GetProcessHeap(), 0, entry->pszTargetName);
742  HeapFree(GetProcessHeap(), 0, entry->pszUsername);
743  SecureZeroMemory(entry->pszPassword, strlenW(entry->pszPassword) * sizeof(WCHAR));
744  HeapFree(GetProcessHeap(), 0, entry->pszPassword);
746 
747  break;
748  }
749  }
750 
752 
753  return result;
754 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static DWORD save_credentials(PCWSTR pszTargetName, PCWSTR pszUsername, PCWSTR pszPassword, BOOL generic)
Definition: credui_main.c:103
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SecureZeroMemory
Definition: winbase.h:1636
static CRITICAL_SECTION csPendingCredentials
Definition: credui_main.c:58
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define debugstr_w
Definition: kernel32.h:32
static struct list pending_credentials_list
Definition: credui_main.c:56
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t entry
Definition: isohybrid.c:63
#define ERROR_NOT_FOUND
Definition: winerror.h:690
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by test_CredUIPromptForCredentials().

◆ CredUIInitControls()

BOOL WINAPI CredUIInitControls ( void  )

Definition at line 857 of file credui_main.c.

858 {
859  FIXME("() stub\n");
860  return TRUE;
861 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110

◆ CredUIParseUserNameW()

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

Definition at line 759 of file credui_main.c.

762 {
763  PWSTR p;
764 
765  TRACE("(%s, %p, %d, %p, %d)\n", debugstr_w(pszUserName), pszUser,
766  ulMaxUserChars, pszDomain, ulMaxDomainChars);
767 
768  if (!pszUserName || !pszUser || !ulMaxUserChars || !pszDomain ||
769  !ulMaxDomainChars)
771 
772  /* FIXME: handle marshaled credentials */
773 
774  p = strchrW(pszUserName, '\\');
775  if (p)
776  {
777  if (p - pszUserName > ulMaxDomainChars - 1)
779  if (strlenW(p + 1) > ulMaxUserChars - 1)
781  strcpyW(pszUser, p + 1);
782  memcpy(pszDomain, pszUserName, (p - pszUserName)*sizeof(WCHAR));
783  pszDomain[p - pszUserName] = '\0';
784 
785  return ERROR_SUCCESS;
786  }
787 
788  p = strrchrW(pszUserName, '@');
789  if (p)
790  {
791  if (p + 1 - pszUserName > ulMaxUserChars - 1)
793  if (strlenW(p + 1) > ulMaxDomainChars - 1)
795  strcpyW(pszDomain, p + 1);
796  memcpy(pszUser, pszUserName, (p - pszUserName)*sizeof(WCHAR));
797  pszUser[p - pszUserName] = '\0';
798 
799  return ERROR_SUCCESS;
800  }
801 
802  if (strlenW(pszUserName) > ulMaxUserChars - 1)
804  strcpyW(pszUser, pszUserName);
805  pszDomain[0] = '\0';
806 
807  return ERROR_SUCCESS;
808 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:54
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
GLfloat GLfloat p
Definition: glext.h:8902
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ 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 597 of file credui_main.c.

606 {
607  INT_PTR ret;
608  struct cred_dialog_params params;
610 
611  TRACE("(%p, %s, %p, %d, %s, %d, %p, %d, %p, 0x%08x)\n", pUIInfo,
614 
616  return ERROR_INVALID_FLAGS;
617 
618  if (!pszTargetName)
620 
621  if ((dwFlags & CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX) && !pfSave)
623 
627  return ERROR_SUCCESS;
628 
629  params.pszTargetName = pszTargetName;
630  if (pUIInfo)
631  {
632  params.pszMessageText = pUIInfo->pszMessageText;
633  params.pszCaptionText = pUIInfo->pszCaptionText;
634  params.hbmBanner = pUIInfo->hbmBanner;
635  }
636  else
637  {
638  params.pszMessageText = NULL;
639  params.pszCaptionText = NULL;
640  params.hbmBanner = NULL;
641  }
642  params.pszUsername = pszUsername;
643  params.ulUsernameMaxChars = ulUsernameMaxChars;
644  params.pszPassword = pszPassword;
645  params.ulPasswordMaxChars = ulPasswordMaxChars;
646  params.fSave = pfSave ? *pfSave : FALSE;
647  params.dwFlags = dwFlags;
648  params.hwndBalloonTip = NULL;
649  params.fBalloonTipActive = FALSE;
650 
652  pUIInfo ? pUIInfo->hwndParent : NULL,
654  if (ret <= 0)
655  return GetLastError();
656 
657  if (ret == IDCANCEL)
658  {
659  TRACE("dialog cancelled\n");
660  return ERROR_CANCELLED;
661  }
662 
663  if (pfSave)
664  *pfSave = params.fSave;
665 
666  if (params.fSave)
667  {
669  {
670  BOOL found = FALSE;
671  struct pending_credentials *entry;
672  int len;
673 
675 
676  /* find existing pending credentials for the same target and overwrite */
677  /* FIXME: is this correct? */
679  if (!strcmpW(pszTargetName, entry->pszTargetName))
680  {
681  found = TRUE;
682  HeapFree(GetProcessHeap(), 0, entry->pszUsername);
683  SecureZeroMemory(entry->pszPassword, strlenW(entry->pszPassword) * sizeof(WCHAR));
684  HeapFree(GetProcessHeap(), 0, entry->pszPassword);
685  }
686 
687  if (!found)
688  {
689  entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
691  entry->pszTargetName = HeapAlloc(GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR));
692  memcpy(entry->pszTargetName, pszTargetName, (len + 1)*sizeof(WCHAR));
694  }
695 
696  len = strlenW(params.pszUsername);
697  entry->pszUsername = HeapAlloc(GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR));
698  memcpy(entry->pszUsername, params.pszUsername, (len + 1)*sizeof(WCHAR));
699  len = strlenW(params.pszPassword);
700  entry->pszPassword = HeapAlloc(GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR));
701  memcpy(entry->pszPassword, params.pszPassword, (len + 1)*sizeof(WCHAR));
702  entry->generic = (dwFlags & CREDUI_FLAGS_GENERIC_CREDENTIALS) != 0;
703 
705  }
706  else if (!(dwFlags & CREDUI_FLAGS_DO_NOT_PERSIST))
709  }
710 
711  return result;
712 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
PCWSTR pszCaptionText
Definition: wincred.h:146
#define TRUE
Definition: types.h:120
static DWORD save_credentials(PCWSTR pszTargetName, PCWSTR pszUsername, PCWSTR pszPassword, BOOL generic)
Definition: credui_main.c:103
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
static INT_PTR CALLBACK CredDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: credui_main.c:486
#define SecureZeroMemory
Definition: winbase.h:1636
static CRITICAL_SECTION csPendingCredentials
Definition: credui_main.c:58
static HINSTANCE hinstCredUI
Definition: credui_main.c:54
HBITMAP hbmBanner
Definition: wincred.h:147
#define CREDUI_FLAGS_INCORRECT_PASSWORD
Definition: wincred.h:223
#define CREDUI_FLAGS_GENERIC_CREDENTIALS
Definition: wincred.h:237
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define IDD_CREDDIALOG
PCWSTR pszMessageText
Definition: wincred.h:145
int32_t INT_PTR
Definition: typedefs.h:62
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static BOOL find_existing_credential(const WCHAR *target, WCHAR *username, ULONG len_username, WCHAR *password, ULONG len_password)
Definition: credui_main.c:561
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define CREDUI_FLAGS_DO_NOT_PERSIST
Definition: wincred.h:224
GLenum const GLfloat * params
Definition: glext.h:5645
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
static struct list pending_credentials_list
Definition: credui_main.c:56
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
#define CREDUI_FLAGS_EXPECT_CONFIRMATION
Definition: wincred.h:236
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CREDUI_FLAGS_ALWAYS_SHOW_UI
Definition: wincred.h:229
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
HWND hwndParent
Definition: wincred.h:144
#define ERROR_CANCELLED
Definition: winerror.h:726
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define IDCANCEL
Definition: winuser.h:825
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX
Definition: wincred.h:228

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 973 of file credui_main.c.

976 {
977  FIXME( "(%p, %u, %p, %p, %u, %p, %p, %p, %08x) stub\n", info, error, package, in_buf, in_buf_size,
978  out_buf, out_buf_size, save, flags );
980 }
#define error(str)
Definition: mkdosfs.c:1605
#define FIXME(fmt,...)
Definition: debug.h:110
GLbitfield flags
Definition: glext.h:7161
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ CredUIReadSSOCredA()

DWORD WINAPI CredUIReadSSOCredA ( PCSTR  pszRealm,
PSTR ppszUsername 
)

Definition at line 835 of file credui_main.c.

836 {
837  FIXME("(%s, %p)\n", debugstr_a(pszRealm), ppszUsername);
838  if (ppszUsername)
839  *ppszUsername = NULL;
840  return ERROR_NOT_FOUND;
841 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_a
Definition: kernel32.h:31
#define ERROR_NOT_FOUND
Definition: winerror.h:690

◆ CredUIReadSSOCredW()

DWORD WINAPI CredUIReadSSOCredW ( PCWSTR  pszRealm,
PWSTR ppszUsername 
)

Definition at line 846 of file credui_main.c.

847 {
848  FIXME("(%s, %p)\n", debugstr_w(pszRealm), ppszUsername);
849  if (ppszUsername)
850  *ppszUsername = NULL;
851  return ERROR_NOT_FOUND;
852 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_NOT_FOUND
Definition: winerror.h:690

◆ CredUIStoreSSOCredA()

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

Definition at line 813 of file credui_main.c.

815 {
816  FIXME("(%s, %s, %p, %d)\n", debugstr_a(pszRealm), debugstr_a(pszUsername),
817  pszPassword, bPersist);
818  return ERROR_SUCCESS;
819 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_a
Definition: kernel32.h:31

◆ CredUIStoreSSOCredW()

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

Definition at line 824 of file credui_main.c.

826 {
827  FIXME("(%s, %s, %p, %d)\n", debugstr_w(pszRealm), debugstr_w(pszUsername),
828  pszPassword, bPersist);
829  return ERROR_SUCCESS;
830 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110

◆ 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 995 of file credui_main.c.

998 {
999  FIXME( "(%08x, %p, %u, %p, %p, %p, %p, %p, %p) stub\n", flags, buf, size, username, len_username,
1000  domain, len_domain, password, len_password );
1002 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FIXME(fmt,...)
Definition: debug.h:110
static WCHAR username[]
Definition: url.c:32
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ DllMain()

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

Definition at line 68 of file credui_main.c.

69 {
70  struct pending_credentials *entry, *cursor2;
71  TRACE("(0x%p, %d, %p)\n",hinstDLL,fdwReason,lpvReserved);
72 
73  switch (fdwReason)
74  {
75  case DLL_WINE_PREATTACH:
76  return FALSE; /* prefer native version */
77 
78  case DLL_PROCESS_ATTACH:
79  DisableThreadLibraryCalls(hinstDLL);
80  hinstCredUI = hinstDLL;
82  break;
83 
84  case DLL_PROCESS_DETACH:
85  if (lpvReserved) break;
87  {
88  list_remove(&entry->entry);
89 
90  HeapFree(GetProcessHeap(), 0, entry->pszTargetName);
91  HeapFree(GetProcessHeap(), 0, entry->pszUsername);
92  SecureZeroMemory(entry->pszPassword, strlenW(entry->pszPassword) * sizeof(WCHAR));
93  HeapFree(GetProcessHeap(), 0, entry->pszPassword);
95  }
97  break;
98  }
99 
100  return TRUE;
101 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define SecureZeroMemory
Definition: winbase.h:1636
static CRITICAL_SECTION csPendingCredentials
Definition: credui_main.c:58
static HINSTANCE hinstCredUI
Definition: credui_main.c:54
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static IN DWORD IN LPVOID lpvReserved
static struct list pending_credentials_list
Definition: credui_main.c:56
#define DLL_PROCESS_DETACH
Definition: compat.h:119
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ 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 561 of file credui_main.c.

563 {
564  DWORD count, i;
565  CREDENTIALW **credentials;
566 
567  if (!CredEnumerateW(target, 0, &count, &credentials)) return FALSE;
568  for (i = 0; i < count; i++)
569  {
570  if (credentials[i]->Type != CRED_TYPE_DOMAIN_PASSWORD &&
571  credentials[i]->Type != CRED_TYPE_GENERIC)
572  {
573  FIXME("no support for type %u credentials\n", credentials[i]->Type);
574  continue;
575  }
576  if ((!*username || !strcmpW(username, credentials[i]->UserName)) &&
577  strlenW(credentials[i]->UserName) < len_username &&
578  credentials[i]->CredentialBlobSize / sizeof(WCHAR) < len_password)
579  {
580  TRACE("found existing credential for %s\n", debugstr_w(credentials[i]->UserName));
581 
582  strcpyW(username, credentials[i]->UserName);
583  memcpy(password, credentials[i]->CredentialBlob, credentials[i]->CredentialBlobSize);
584  password[credentials[i]->CredentialBlobSize / sizeof(WCHAR)] = 0;
585 
586  CredFree(credentials);
587  return TRUE;
588  }
589  }
590  CredFree(credentials);
591  return FALSE;
592 }
DWORD CredentialBlobSize
Definition: wincred.h:89
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
Type
Definition: Type.h:6
GLuint GLuint GLsizei count
Definition: gl.h:1545
BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIALW **Credentials)
Definition: cred.c:1289
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
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define CRED_TYPE_DOMAIN_PASSWORD
Definition: wincred.h:205
static WCHAR username[]
Definition: url.c:32
#define TRACE(s)
Definition: solgame.cpp:4
VOID WINAPI CredFree(PVOID Buffer)
Definition: cred.c:1395
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define CRED_TYPE_GENERIC
Definition: wincred.h:204
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
GLenum target
Definition: glext.h:7315

Referenced by CredUIPromptForCredentialsW(), and SspiPromptForCredentialsW().

◆ save_credentials()

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

Definition at line 103 of file credui_main.c.

105 {
106  CREDENTIALW cred;
107 
108  TRACE("saving servername %s with username %s\n", debugstr_w(pszTargetName), debugstr_w(pszUsername));
109 
110  cred.Flags = 0;
113  cred.Comment = NULL;
114  cred.CredentialBlobSize = strlenW(pszPassword) * sizeof(WCHAR);
117  cred.AttributeCount = 0;
118  cred.Attributes = NULL;
119  cred.TargetAlias = NULL;
120  cred.UserName = (LPWSTR)pszUsername;
121 
122  if (CredWriteW(&cred, 0))
123  return ERROR_SUCCESS;
124  else
125  {
126  DWORD ret = GetLastError();
127  ERR("CredWriteW failed with error %d\n", ret);
128  return ret;
129  }
130 }
DWORD CredentialBlobSize
Definition: wincred.h:89
LPBYTE CredentialBlob
Definition: wincred.h:90
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD AttributeCount
Definition: wincred.h:92
LPWSTR UserName
Definition: wincred.h:95
BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags)
Definition: cred.c:1809
unsigned char * LPBYTE
Definition: typedefs.h:52
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define CRED_TYPE_DOMAIN_PASSWORD
Definition: wincred.h:205
#define CRED_PERSIST_ENTERPRISE
Definition: wincred.h:216
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD Flags
Definition: wincred.h:84
LPWSTR TargetAlias
Definition: wincred.h:94
LPWSTR TargetName
Definition: wincred.h:86
unsigned long DWORD
Definition: ntddk_ex.h:95
PCREDENTIAL_ATTRIBUTEW Attributes
Definition: wincred.h:93
int ret
#define CRED_TYPE_GENERIC
Definition: wincred.h:204
DWORD Type
Definition: wincred.h:85
DWORD Persist
Definition: wincred.h:91
#define ERR(fmt,...)
Definition: debug.h:109
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPWSTR Comment
Definition: wincred.h:87

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 866 of file credui_main.c.

871 {
872  static const WCHAR basicW[] = {'B','a','s','i','c',0};
873  static const WCHAR ntlmW[] = {'N','T','L','M',0};
874  static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',0};
877  DWORD len_username = ARRAY_SIZE(username);
878  DWORD len_password = ARRAY_SIZE(password);
879  DWORD ret, flags;
880  CREDUI_INFOW *cred_info = info;
881  SEC_WINNT_AUTH_IDENTITY_W *id = input_id;
882 
883  FIXME( "(%s, %p, %u, %s, %p, %p, %p, %x) stub\n", debugstr_w(target), info,
884  error, debugstr_w(package), input_id, output_id, save, sspi_flags );
885 
886  if (!target) return ERROR_INVALID_PARAMETER;
887  if (!package || (strcmpiW( package, basicW ) && strcmpiW( package, ntlmW ) &&
888  strcmpiW( package, negotiateW )))
889  {
890  FIXME( "package %s not supported\n", debugstr_w(package) );
891  return ERROR_NO_SUCH_PACKAGE;
892  }
893 
895 
896  if (sspi_flags & SSPIPFC_CREDPROV_DO_NOT_SAVE)
898 
899  if (!(sspi_flags & SSPIPFC_NO_CHECKBOX))
901 
902  if (!id) find_existing_credential( target, username, len_username, password, len_password );
903  else
904  {
905  if (id->User && id->UserLength > 0 && id->UserLength <= CREDUI_MAX_USERNAME_LENGTH)
906  {
907  memcpy( username, id->User, id->UserLength * sizeof(WCHAR) );
908  username[id->UserLength] = 0;
909  }
910  if (id->Password && id->PasswordLength > 0 && id->PasswordLength <= CREDUI_MAX_PASSWORD_LENGTH)
911  {
912  memcpy( password, id->Password, id->PasswordLength * sizeof(WCHAR) );
913  password[id->PasswordLength] = 0;
914  }
915  }
916 
917  if (!(ret = CredUIPromptForCredentialsW( cred_info, target, NULL, error, username,
918  len_username, password, len_password, save, flags )))
919  {
920  DWORD size = sizeof(*id), len_domain = 0;
921  WCHAR *ptr, *user = username, *domain = NULL;
922 
923  if ((ptr = strchrW( username, '\\' )))
924  {
925  user = ptr + 1;
926  len_username = strlenW( user );
927  if (!strcmpiW( package, ntlmW ) || !strcmpiW( package, negotiateW ))
928  {
929  domain = username;
930  len_domain = ptr - username;
931  }
932  *ptr = 0;
933  }
934  else len_username = strlenW( username );
935  len_password = strlenW( password );
936 
937  size += (len_username + 1) * sizeof(WCHAR);
938  size += (len_domain + 1) * sizeof(WCHAR);
939  size += (len_password + 1) * sizeof(WCHAR);
940  if (!(id = HeapAlloc( GetProcessHeap(), 0, size ))) return ERROR_OUTOFMEMORY;
941  ptr = (WCHAR *)(id + 1);
942 
943  memcpy( ptr, user, (len_username + 1) * sizeof(WCHAR) );
944  id->User = ptr;
945  id->UserLength = len_username;
946  ptr += len_username + 1;
947  if (len_domain)
948  {
949  memcpy( ptr, domain, (len_domain + 1) * sizeof(WCHAR) );
950  id->Domain = ptr;
951  id->DomainLength = len_domain;
952  ptr += len_domain + 1;
953  }
954  else
955  {
956  id->Domain = NULL;
957  id->DomainLength = 0;
958  }
959  memcpy( ptr, password, (len_password + 1) * sizeof(WCHAR) );
960  id->Password = ptr;
961  id->PasswordLength = len_password;
962  id->Flags = 0;
963 
964  *output_id = id;
965  }
966 
967  return ret;
968 }
static const WCHAR basicW[]
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define SSPIPFC_CREDPROV_DO_NOT_SAVE
Definition: sspi.h:80
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define error(str)
Definition: mkdosfs.c:1605
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:597
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define CREDUI_FLAGS_GENERIC_CREDENTIALS
Definition: wincred.h:237
static BOOL find_existing_credential(const WCHAR *target, WCHAR *username, ULONG len_username, WCHAR *password, ULONG len_password)
Definition: credui_main.c:561
static const WCHAR negotiateW[]
struct _test_info info[]
Definition: SetCursorPos.c:19
#define CREDUI_FLAGS_DO_NOT_PERSIST
Definition: wincred.h:224
#define CREDUI_MAX_USERNAME_LENGTH
Definition: wincred.h:193
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
#define CREDUI_MAX_PASSWORD_LENGTH
Definition: wincred.h:194
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR ntlmW[]
static WCHAR username[]
Definition: url.c:32
#define SSPIPFC_NO_CHECKBOX
Definition: sspi.h:81
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CREDUI_FLAGS_ALWAYS_SHOW_UI
Definition: wincred.h:229
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define ERROR_NO_SUCH_PACKAGE
Definition: winerror.h:845
int ret
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define ARRAY_SIZE(a)
Definition: main.h:24
GLenum GLuint id
Definition: glext.h:5579
GLenum target
Definition: glext.h:7315
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX
Definition: wincred.h:228
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

◆ 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") }
}
#define DWORD_PTR
Definition: treelist.c:76
static CRITICAL_SECTION csPendingCredentials
Definition: credui_main.c:58
LIST_ENTRY ProcessLocksList
Definition: winbase.h:848
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: credui_main.c:59

Definition at line 59 of file credui_main.c.

◆ csPendingCredentials

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

Definition at line 58 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 56 of file credui_main.c.

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