Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2020 lines
63 KiB

  1. /*
  2. File: ProvUI.cpp
  3. Title: Base provider user interface
  4. Author: Matt Thomlinson
  5. Date: 12/13/96
  6. ProvUI houses all user interface for the provider. During
  7. startup, InitUI() fetches all user strings from the resource
  8. string table. During shutdown, ReleaseUI() frees them.
  9. The other miscellaneous functions gather passwords,
  10. define new password groups and retrieve the windows password
  11. if it has changed.
  12. */
  13. #include <pch.cpp>
  14. #pragma hdrstop
  15. #include <commctrl.h>
  16. #include "provui.h"
  17. #include "storage.h"
  18. #include "passwd.h"
  19. #include "filemisc.h"
  20. extern DISPIF_CALLBACKS g_sCallbacks;
  21. extern PRIVATE_CALLBACKS g_sPrivateCallbacks;
  22. extern HINSTANCE g_hInst;
  23. extern BOOL g_fAllowCachePW;
  24. // cached authentication list
  25. extern CUAList* g_pCUAList;
  26. HICON g_DefaultIcon = NULL;
  27. BOOL g_fUIInitialized = FALSE;
  28. CRITICAL_SECTION g_csUIInitialized;
  29. // string resources
  30. LPWSTR g_StringBlock = NULL; // single allocated block containing all sz strings
  31. LPWSTR g_ItemDetailsBannerMessage;
  32. LPWSTR g_PasswordDuplicate;
  33. LPWSTR g_PasswordAddError;
  34. LPWSTR g_PasswordChangeError;
  35. LPWSTR g_PasswordCreate;
  36. LPWSTR g_PasswordNoMatch;
  37. LPWSTR g_PasswordMustName;
  38. LPWSTR g_PasswordChange;
  39. LPWSTR g_PasswordSolicitOld;
  40. LPWSTR g_PasswordErrorDlgTitle;
  41. LPWSTR g_PasswordWin95Garbage;
  42. LPWSTR g_PasswordNoVerify;
  43. LPWSTR g_PasswordWinNoVerify;
  44. LPWSTR g_PWPromptPrefix;
  45. LPWSTR g_PWPromptSuffix;
  46. LPWSTR g_SimplifiedDlgMessageFormat;
  47. LPWSTR g_PromptReadItem;
  48. LPWSTR g_PromptOpenItem;
  49. LPWSTR g_PromptWriteItem;
  50. LPWSTR g_PromptDeleteItem;
  51. LPWSTR g_PromptHighSecurity;
  52. LPWSTR g_PromptMedSecurity;
  53. LPWSTR g_PromptLowSecurity;
  54. LPWSTR g_TitleContainerMapping;
  55. #define MAX_PW_LEN 160
  56. #define MAX_STRING_RSC_SIZE 512
  57. // define something not likely to be entered by a user
  58. #define WSZ_PASSWORD_CHANGE_DETECT_TOKEN L"[]{}9d1Dq"
  59. //
  60. // this one comes and goes only when needed
  61. //
  62. typedef DWORD (WINAPI *WNETVERIFYPASSWORD)(
  63. LPCSTR lpszPassword,
  64. BOOL *pfMatch
  65. );
  66. ///////////////////////////////////////////////////////////////////////////
  67. // Forwards
  68. INT_PTR CALLBACK DialogAdvancedConfirmH(
  69. HWND hDlg, // handle to dialog box
  70. UINT message, // message
  71. WPARAM wParam, // first message parameter
  72. LPARAM lParam // second message parameter
  73. );
  74. INT_PTR CALLBACK DialogAccessDetails(
  75. HWND hDlg, // handle to dialog box
  76. UINT message, // message
  77. WPARAM wParam, // first message parameter
  78. LPARAM lParam // second message parameter
  79. );
  80. INT_PTR CALLBACK DialogSetSecurityLevel(
  81. HWND hDlg, // handle to dialog box
  82. UINT message, // message
  83. WPARAM wParam, // first message parameter
  84. LPARAM lParam // second message parameter
  85. );
  86. INT_PTR CALLBACK DialogSimplifiedPasswordConfirm(
  87. HWND hDlg, // handle to dialog box
  88. UINT message, // message
  89. WPARAM wParam, // first message parameter
  90. LPARAM lParam // second message parameter
  91. );
  92. INT_PTR CALLBACK DialogWaitForOKCancel(
  93. HWND hDlg, // handle to dialog box
  94. UINT message, // message
  95. WPARAM wParam, // first message parameter
  96. LPARAM lParam // second message parameter
  97. );
  98. int
  99. ServicesDialogBoxParam(
  100. HINSTANCE hInstance, // handle to application instance
  101. LPCTSTR lpTemplateName, // identifies dialog box template
  102. HWND hWndParent, // handle to owner window
  103. DLGPROC lpDialogFunc, // pointer to dialog box procedure
  104. LPARAM dwInitParam // initialization value
  105. );
  106. BOOL
  107. FetchString(
  108. HMODULE hModule, // module to get string from
  109. UINT ResourceId, // resource identifier
  110. LPWSTR *String, // target buffer for string
  111. LPWSTR *StringBlock, // string buffer block
  112. DWORD *dwBufferSize, // size of string buffer block
  113. DWORD *dwRemainingBufferSize // remaining size of string buffer block
  114. );
  115. BOOL
  116. CALLBACK
  117. FMyLoadIcon(
  118. HINSTANCE hModule, // resource-module handle
  119. LPCTSTR lpszType, // pointer to resource type
  120. LPWSTR lpszName, // pointer to resource name
  121. LONG_PTR lParam // application-defined parameter
  122. );
  123. ///////////////////////////////////////////////////////////////////////////
  124. // Exposed functions
  125. #define GLOBAL_STRING_BUFFERSIZE 3800
  126. BOOL InitUI()
  127. {
  128. DWORD dwBufferSize;
  129. DWORD dwRemainingBufferSize;
  130. BOOL bSuccess = FALSE;
  131. if( g_fUIInitialized )
  132. return TRUE;
  133. //
  134. // take crit sec
  135. //
  136. EnterCriticalSection( &g_csUIInitialized );
  137. //
  138. // check the global to prevent a race condition that would cause
  139. // re-init to occur.
  140. //
  141. if( g_fUIInitialized ) {
  142. bSuccess = TRUE;
  143. goto cleanup;
  144. }
  145. g_DefaultIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON1));
  146. if(g_DefaultIcon == NULL)
  147. goto cleanup;
  148. //
  149. // get size of all string resources, and then allocate a single block
  150. // of memory to contain all the strings. This way, we only have to
  151. // free one block and we benefit memory wise due to locality of reference.
  152. //
  153. dwBufferSize = dwRemainingBufferSize = GLOBAL_STRING_BUFFERSIZE;
  154. g_StringBlock = (LPWSTR)SSAlloc(dwBufferSize);
  155. if(g_StringBlock == NULL)
  156. goto cleanup;
  157. if(!FetchString(g_hInst, IDS_ITEM_DETAILS_BANNER, &g_ItemDetailsBannerMessage, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  158. goto cleanup;
  159. if(!FetchString(g_hInst, IDS_PASSWORD_CREATE_MESSAGE, &g_PasswordCreate, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  160. goto cleanup;
  161. if(!FetchString(g_hInst, IDS_PASSWORD_NOMATCH, &g_PasswordNoMatch, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  162. goto cleanup;
  163. if(!FetchString(g_hInst, IDS_PASSWORD_CHANGE_MESSAGE, &g_PasswordChange, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  164. goto cleanup;
  165. if(!FetchString(g_hInst, IDS_PASSWORD_MUSTNAME, &g_PasswordMustName, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  166. goto cleanup;
  167. if(!FetchString(g_hInst, IDS_PASSWORD_SOLICIT_OLD_MESSAGE, &g_PasswordSolicitOld, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  168. goto cleanup;
  169. if(!FetchString(g_hInst, IDS_PASSWORD_DUPLICATE, &g_PasswordDuplicate, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  170. goto cleanup;
  171. if(!FetchString(g_hInst, IDS_PASSWORD_ADD_ERROR, &g_PasswordAddError, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  172. goto cleanup;
  173. if(!FetchString(g_hInst, IDS_PASSWORD_CHANGE_ERROR, &g_PasswordChangeError, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  174. goto cleanup;
  175. if(!FetchString(g_hInst, IDS_PASSWORD_ERROR_DLGTITLE, &g_PasswordErrorDlgTitle, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  176. goto cleanup;
  177. if(!FetchString(g_hInst, IDS_WIN95_PASSWORDS_AREGARBAGE, &g_PasswordWin95Garbage, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  178. goto cleanup;
  179. if(!FetchString(g_hInst, IDS_PASSWORD_NOVERIFY, &g_PasswordNoVerify, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  180. goto cleanup;
  181. if(!FetchString(g_hInst, IDS_PASSWORD_WIN_NOVERIFY, &g_PasswordWinNoVerify, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  182. goto cleanup;
  183. if(!FetchString(g_hInst, IDS_PASSWORD_PROMPT_PREFIX, &g_PWPromptPrefix, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  184. goto cleanup;
  185. if(!FetchString(g_hInst, IDS_PASSWORD_PROMPT_SUFFIX, &g_PWPromptSuffix, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  186. goto cleanup;
  187. if(!FetchString(g_hInst, IDS_SIMPLIFIED_DLG_MSG, &g_SimplifiedDlgMessageFormat, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  188. goto cleanup;
  189. if(!FetchString(g_hInst, IDS_PROMPT_READITEM, &g_PromptReadItem, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  190. goto cleanup;
  191. if(!FetchString(g_hInst, IDS_PROMPT_OPENITEM, &g_PromptOpenItem, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  192. goto cleanup;
  193. if(!FetchString(g_hInst, IDS_PROMPT_WRITEITEM, &g_PromptWriteItem, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  194. goto cleanup;
  195. if(!FetchString(g_hInst, IDS_PROMPT_DELETEITEM, &g_PromptDeleteItem, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  196. goto cleanup;
  197. if(!FetchString(g_hInst, IDS_PROMPT_HIGH_SECURITY, &g_PromptHighSecurity, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  198. goto cleanup;
  199. if(!FetchString(g_hInst, IDS_PROMPT_MED_SECURITY, &g_PromptMedSecurity, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  200. goto cleanup;
  201. if(!FetchString(g_hInst, IDS_PROMPT_LOW_SECURITY, &g_PromptLowSecurity, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  202. goto cleanup;
  203. if(!FetchString(g_hInst, IDS_TITLE_CONTAINER_MAPPING, &g_TitleContainerMapping, &g_StringBlock, &dwBufferSize, &dwRemainingBufferSize))
  204. goto cleanup;
  205. //
  206. // if the block was realloc'ed to a different location, re-fetch strings
  207. // very unlikely to ever happen
  208. //
  209. #if DBG
  210. if(GLOBAL_STRING_BUFFERSIZE != dwBufferSize)
  211. OutputDebugString(TEXT("Forced to realloc global string area in provui.cpp:InitUI()\n"));
  212. #endif
  213. bSuccess = TRUE;
  214. cleanup:
  215. if(!bSuccess) {
  216. if(g_StringBlock) {
  217. SSFree(g_StringBlock);
  218. g_StringBlock = NULL;
  219. }
  220. } else {
  221. g_fUIInitialized = TRUE;
  222. }
  223. LeaveCriticalSection( &g_csUIInitialized );
  224. return bSuccess;
  225. }
  226. BOOL ReleaseUI()
  227. {
  228. g_DefaultIcon = NULL;
  229. if(g_StringBlock) {
  230. SSFree(g_StringBlock);
  231. g_StringBlock = NULL;
  232. }
  233. #if 0
  234. g_PasswordDuplicate = g_PasswordAddError = g_PasswordChangeError =
  235. g_PasswordCreate = g_PasswordNoMatch = g_PasswordMustName = g_PasswordChange =
  236. g_PasswordSolicitOld = g_PasswordErrorDlgTitle = g_PasswordWin95Garbage =
  237. g_PasswordNoVerify = g_PasswordWinNoVerify =
  238. g_PWPromptPrefix = g_PWPromptSuffix = g_SimplifiedDlgMessageFormat =
  239. g_PromptReadItem = g_PromptOpenItem = g_PromptWriteItem =
  240. g_PromptDeleteItem = g_PromptHighSecurity = g_PromptMedSecurity =
  241. g_PromptLowSecurity =
  242. NULL;
  243. #endif
  244. return TRUE;
  245. }
  246. BOOL
  247. FIsProviderUIAllowed(
  248. LPCWSTR szUser
  249. )
  250. {
  251. //
  252. // UI always allowed under Win95.
  253. //
  254. if(!FIsWinNT())
  255. return TRUE;
  256. //
  257. // UI is not allowed on NT when running as local system.
  258. //
  259. if(lstrcmpiW(szUser, TEXTUAL_SID_LOCAL_SYSTEM) == 0)
  260. return FALSE;
  261. return TRUE;
  262. }
  263. LPWSTR SZMakeDisplayableType(LPCWSTR szType,LPCWSTR szSubtype)
  264. {
  265. // create a nice UI string
  266. LPWSTR szUIType = (LPWSTR)SSAlloc((
  267. wcslen(szType)+
  268. 3 + // L" ()"
  269. wcslen(szSubtype) +
  270. 1 // L"\0"
  271. ) * sizeof(WCHAR));
  272. if(szUIType == NULL)
  273. return FALSE;
  274. // sprintf: Subtype(Type)
  275. wcscpy(szUIType, szSubtype);
  276. wcscat(szUIType, L" (");
  277. wcscat(szUIType, szType);
  278. wcscat(szUIType, L")");
  279. return szUIType;
  280. }
  281. BOOL
  282. MyGetPwdHashEx(
  283. LPWSTR szPW,
  284. BYTE rgbPasswordDerivedBytes[A_SHA_DIGEST_LEN],
  285. BOOL fLowerCase
  286. )
  287. {
  288. A_SHA_CTX sSHAHash;
  289. DWORD cbPassword;
  290. LPWSTR TemporaryPassword = NULL;
  291. LPWSTR PasswordToHash;
  292. // don't include NULL termination
  293. cbPassword = WSZ_BYTECOUNT(szPW) - sizeof(WCHAR);
  294. if ( fLowerCase )
  295. {
  296. TemporaryPassword = (LPWSTR) SSAlloc( cbPassword + sizeof(WCHAR) );
  297. if( TemporaryPassword == NULL )
  298. return FALSE;
  299. CopyMemory(TemporaryPassword, szPW, cbPassword + sizeof(WCHAR) );
  300. //
  301. // Win95: inconsistent handling of pwds
  302. // forces inplace convert to uppercase
  303. //
  304. MyToUpper(TemporaryPassword);
  305. PasswordToHash = TemporaryPassword;
  306. } else {
  307. PasswordToHash = szPW;
  308. }
  309. // hash pwd, copy out
  310. A_SHAInit(&sSHAHash);
  311. // Hash password
  312. A_SHAUpdate(&sSHAHash, (BYTE *) PasswordToHash, cbPassword);
  313. A_SHAFinal(&sSHAHash, rgbPasswordDerivedBytes);
  314. if( TemporaryPassword )
  315. SSFree( TemporaryPassword );
  316. return TRUE;
  317. }
  318. BOOL
  319. MyGetPwdHash(
  320. LPWSTR szPW,
  321. BYTE rgbPasswordDerivedBytes[A_SHA_DIGEST_LEN]
  322. )
  323. {
  324. if (!FIsWinNT())
  325. {
  326. // Win95: inconsistent handling of pwds
  327. // forces inplace convert to uppercase
  328. MyGetPwdHashEx( szPW, rgbPasswordDerivedBytes, TRUE );
  329. } else {
  330. MyGetPwdHashEx( szPW, rgbPasswordDerivedBytes, FALSE );
  331. }
  332. return TRUE;
  333. }
  334. BOOL
  335. FetchString(
  336. HMODULE hModule, // module to get string from
  337. UINT ResourceId, // resource identifier
  338. LPWSTR *String, // target buffer for string
  339. LPWSTR *StringBlock, // string buffer block
  340. DWORD *dwBufferSize, // size of string buffer block
  341. DWORD *dwRemainingBufferSize // remaining size of string buffer block
  342. )
  343. {
  344. WCHAR szMessage[MAX_STRING_RSC_SIZE];
  345. DWORD cchMessage;
  346. if(StringBlock == NULL || *StringBlock == NULL || String == NULL)
  347. return FALSE;
  348. cchMessage = LoadStringU(
  349. hModule,
  350. ResourceId,
  351. szMessage,
  352. MAX_STRING_RSC_SIZE);
  353. if(cchMessage == 0)
  354. return FALSE;
  355. if(*dwRemainingBufferSize < (cchMessage+1) * sizeof(WCHAR)) {
  356. //
  357. // realloc buffer and update size
  358. //
  359. LPWSTR TempStr = NULL;
  360. DWORD dwOldSize = *dwBufferSize;
  361. DWORD dwNewSize = dwOldSize + ((cchMessage + 1) * sizeof(WCHAR)) ;
  362. TempStr = (LPWSTR)SSReAlloc( *StringBlock, dwNewSize );
  363. if(TempStr == NULL) {
  364. //
  365. // dwNewSize will never be 0. *StringBlock should not be freed when NULL is returned.
  366. // The caller should take care of *StringBlock.
  367. //
  368. return FALSE;
  369. }
  370. *StringBlock = TempStr;
  371. *dwBufferSize = dwNewSize;
  372. *dwRemainingBufferSize += dwNewSize - dwOldSize;
  373. }
  374. *String = (LPWSTR)((LPBYTE)*StringBlock + *dwBufferSize - *dwRemainingBufferSize);
  375. wcscpy(*String, szMessage);
  376. *dwRemainingBufferSize -= (cchMessage + 1) * sizeof(WCHAR);
  377. return TRUE;
  378. }
  379. int
  380. ServicesDialogBoxParam(
  381. HINSTANCE hInstance, // handle to application instance
  382. LPCTSTR lpTemplateName, // identifies dialog box template
  383. HWND hWndParent, // handle to owner window
  384. DLGPROC lpDialogFunc, // pointer to dialog box procedure
  385. LPARAM dwInitParam // initialization value
  386. )
  387. /*++
  388. This function is implemented to allow UI to originate from the
  389. Protected Storage service on Windows NT 5.0 installations.
  390. This UI will go to the user desktop, rather than an invisible desktop
  391. which would otherwise cause DialogBoxParam() calls to fail.
  392. --*/
  393. {
  394. HWINSTA hOldWinsta = NULL;
  395. HWINSTA hNewWinsta = NULL;
  396. HDESK hOldDesk = NULL;
  397. HDESK hNewDesk = NULL;
  398. int iRet = -1;
  399. if( FIsWinNT5() ) {
  400. hOldWinsta = GetProcessWindowStation();
  401. if(hOldWinsta == NULL)
  402. goto cleanup;
  403. hOldDesk = GetThreadDesktop( GetCurrentThreadId() );
  404. if(hOldDesk == NULL)
  405. goto cleanup;
  406. hNewWinsta = OpenWindowStationW( L"WinSta0", FALSE, MAXIMUM_ALLOWED );
  407. if(hNewWinsta == NULL)
  408. goto cleanup;
  409. if(!SetProcessWindowStation( hNewWinsta ))
  410. goto cleanup;
  411. hNewDesk = OpenDesktopW( L"default", 0, FALSE, MAXIMUM_ALLOWED );
  412. if(hNewDesk == NULL)
  413. goto cleanup;
  414. if(!SetThreadDesktop( hNewDesk )) {
  415. if( GetLastError() != ERROR_BUSY )
  416. goto cleanup;
  417. //
  418. // the desktop object is locked/in-use. Most likely explanation
  419. // is nested dialog box calls. Just put the process windowstation
  420. // back and continue..
  421. //
  422. SetProcessWindowStation( hOldWinsta );
  423. }
  424. }
  425. INITCOMMONCONTROLSEX initcomm;
  426. initcomm.dwSize = sizeof(initcomm);
  427. initcomm.dwICC = ICC_STANDARD_CLASSES | ICC_WIN95_CLASSES;
  428. InitCommonControlsEx(&initcomm);
  429. iRet = (int)DialogBoxParam(
  430. hInstance, // handle to application instance
  431. lpTemplateName, // identifies dialog box template
  432. hWndParent, // handle to owner window
  433. lpDialogFunc, // pointer to dialog box procedure
  434. dwInitParam // initialization value
  435. );
  436. cleanup:
  437. if( hOldWinsta ) {
  438. SetProcessWindowStation( hOldWinsta );
  439. }
  440. if( hOldDesk ) {
  441. SetThreadDesktop( hOldDesk );
  442. }
  443. if( hNewWinsta ) {
  444. CloseWindowStation( hNewWinsta );
  445. }
  446. if( hNewDesk ) {
  447. CloseDesktop( hNewDesk );
  448. }
  449. return iRet;
  450. }
  451. ///////////////////////////////////////////////////////////////////////////
  452. ///////////////////////////////////////////////////////////////////////////
  453. // exposed Dialog setup functions
  454. BOOL FSimplifiedPasswordConfirm(
  455. PST_PROVIDER_HANDLE* phPSTProv,
  456. LPCWSTR szUserName,
  457. LPCWSTR szCallerName,
  458. LPCWSTR szType,
  459. LPCWSTR szSubtype,
  460. LPCWSTR szItemName,
  461. PPST_PROMPTINFO psPrompt,
  462. LPCWSTR szAccessType,
  463. LPWSTR* ppszPWName,
  464. DWORD* pdwPasswordOptions,
  465. BOOL fAllowUserFreedom,
  466. BYTE rgbPasswordDerivedBytes[],
  467. DWORD cbPasswordDerivedBytes,
  468. BYTE rgbPasswordDerivedBytesLowerCase[],
  469. DWORD cbPasswordDerivedBytesLowerCase,
  470. DWORD dwFlags
  471. )
  472. {
  473. if ((rgbPasswordDerivedBytes == NULL) || (cbPasswordDerivedBytes < A_SHA_DIGEST_LEN))
  474. return FALSE;
  475. if ((rgbPasswordDerivedBytesLowerCase == NULL) || (cbPasswordDerivedBytesLowerCase < A_SHA_DIGEST_LEN))
  476. return FALSE;
  477. BOOL fRet = FALSE;
  478. LPWSTR pszUIPassword = NULL; // actual pwd
  479. LPWSTR szUIType = NULL;
  480. BOOL fCacheThisPasswd; // unDONE UNDONE going away
  481. DWORD cchItemName;
  482. LPCWSTR szTitle = szItemName; // default titlebar to itemname.
  483. //
  484. // check if szItemName is a GUID, if so, map the title to something legible.
  485. //
  486. cchItemName = lstrlenW( szItemName );
  487. if( cchItemName == 36 ) {
  488. if( szItemName[ 8 ] == L'-' &&
  489. szItemName[ 13 ] == L'-' &&
  490. szItemName[ 18 ] == L'-' &&
  491. szItemName[ 23 ] == L'-' ) {
  492. szTitle = g_TitleContainerMapping;
  493. }
  494. } else if( cchItemName == 38 ) {
  495. if( szItemName[ 0 ] == L'{' &&
  496. szItemName[ 9 ] == L'-' &&
  497. szItemName[ 14 ] == L'-' &&
  498. szItemName[ 19 ] == L'-' &&
  499. szItemName[ 24 ] == L'-' &&
  500. szItemName[ 37 ] == L'}' ) {
  501. szTitle = g_TitleContainerMapping;
  502. }
  503. }
  504. if (NULL == (szUIType =
  505. SZMakeDisplayableType(
  506. szType,
  507. szSubtype)) )
  508. return FALSE;
  509. int iRet;
  510. // PST_ flags go in..
  511. // okay, take the hit
  512. PW_DIALOG_ARGS DialogArgs =
  513. {
  514. phPSTProv,
  515. szCallerName,
  516. szAccessType,
  517. psPrompt->szPrompt,
  518. szUIType,
  519. szTitle,
  520. szUserName,
  521. ppszPWName,
  522. &pszUIPassword,
  523. pdwPasswordOptions,
  524. fAllowUserFreedom, // allow user to change protection?
  525. &fCacheThisPasswd,
  526. rgbPasswordDerivedBytes,
  527. rgbPasswordDerivedBytesLowerCase
  528. };
  529. if(FIsWinNT()) {
  530. BOOL fAuthID;
  531. if (!g_sCallbacks.pfnFImpersonateClient( phPSTProv )) {
  532. goto Ret;
  533. }
  534. fAuthID = GetThreadAuthenticationId(GetCurrentThread(), &(DialogArgs.luidAuthID));
  535. g_sCallbacks.pfnFRevertToSelf( phPSTProv );
  536. if( !fAuthID ) {
  537. goto Ret;
  538. }
  539. }
  540. DialogArgs.dwFlags = dwFlags;
  541. iRet = ServicesDialogBoxParam(
  542. g_hInst,
  543. MAKEINTRESOURCE(IDD_SIMPLIFIED_PASSWD),
  544. (HWND)psPrompt->hwndApp,
  545. DialogSimplifiedPasswordConfirm,
  546. (LPARAM)&DialogArgs);
  547. if(iRet != IDOK) goto Ret;
  548. // BP_ flags, derived bytes come out
  549. fRet = TRUE;
  550. Ret:
  551. if (pszUIPassword)
  552. SSFree(pszUIPassword);
  553. if (szUIType)
  554. SSFree(szUIType);
  555. return fRet;
  556. }
  557. BOOL FInternal_CreateNewPasswordEntry(
  558. HWND hParentWnd,
  559. LPCWSTR szUserName,
  560. LPWSTR szPWName,
  561. LPWSTR szPW)
  562. {
  563. BOOL fRet = FALSE;
  564. BYTE rgbPasswordDerivedBytes[A_SHA_DIGEST_LEN];
  565. // and check response
  566. if ((szPW == NULL) || (szPWName == NULL))
  567. goto Ret;
  568. // everything went fine, now derive the password bits!
  569. if (!MyGetPwdHash(szPW, rgbPasswordDerivedBytes))
  570. goto Ret;
  571. // and now commit change
  572. if (!FPasswordChangeNotify(
  573. szUserName,
  574. szPWName,
  575. NULL,
  576. 0,
  577. rgbPasswordDerivedBytes,
  578. A_SHA_DIGEST_LEN ))
  579. {
  580. LPWSTR szMessage;
  581. if (PST_E_ITEM_EXISTS == GetLastError())
  582. {
  583. szMessage = g_PasswordDuplicate;
  584. }
  585. else
  586. {
  587. szMessage = g_PasswordAddError;
  588. }
  589. // this W implemented in both Win95 & NT!
  590. MessageBoxW(
  591. NULL, //hParentWnd,
  592. szMessage,
  593. g_PasswordErrorDlgTitle,
  594. MB_OK | MB_ICONEXCLAMATION | MB_SERVICE_NOTIFICATION);
  595. goto Ret;
  596. }
  597. fRet = TRUE;
  598. Ret:
  599. return fRet;
  600. }
  601. BOOL
  602. ChooseSecurityWizard(HWND hDlg, ADVANCEDCONFIRM_DIALOGARGS* pDialogArgs)
  603. {
  604. // make copy of pDialogArgs so we don't change original
  605. // unless everything goes ok
  606. LPWSTR szPWName_Stack = NULL;
  607. LPWSTR szPW_Stack = NULL; // no need to pull original password out
  608. DWORD dwPasswordOptions_Stack;
  609. DWORD dwReturnStatus;
  610. ADVANCEDCONFIRM_DIALOGARGS DlgArgs_Stack = {
  611. pDialogArgs->szUserName,
  612. &szPWName_Stack,
  613. &szPW_Stack,
  614. &dwPasswordOptions_Stack,
  615. pDialogArgs->szItemName};
  616. if(*(pDialogArgs->ppszPWName) != NULL)
  617. {
  618. szPWName_Stack = (LPWSTR)SSAlloc(WSZ_BYTECOUNT(*(pDialogArgs->ppszPWName)));
  619. if(szPWName_Stack == NULL)
  620. {
  621. goto Ret;
  622. }
  623. wcscpy(szPWName_Stack, *(pDialogArgs->ppszPWName));
  624. }
  625. dwPasswordOptions_Stack = *(pDialogArgs->pdwPasswordOptions);
  626. Choose_Step1:
  627. dwReturnStatus = ServicesDialogBoxParam(
  628. g_hInst,
  629. MAKEINTRESOURCE(IDD_ADVANCED_CONFIRM),
  630. (HWND)hDlg,
  631. DialogSetSecurityLevel,
  632. (LPARAM)&DlgArgs_Stack);
  633. // if user decides not to choose, bail
  634. if (IDOK != dwReturnStatus)
  635. goto Ret;
  636. // else, switch on his decision
  637. switch (*(DlgArgs_Stack.pdwPasswordOptions))
  638. {
  639. case (BP_CONFIRM_PASSWORDUI):
  640. {
  641. dwReturnStatus =
  642. ServicesDialogBoxParam(
  643. g_hInst,
  644. MAKEINTRESOURCE(IDD_ADVANCED_CONFIRM_H),
  645. (HWND)hDlg,
  646. DialogAdvancedConfirmH,
  647. (LPARAM)&DlgArgs_Stack);
  648. // if user hits okay, execute
  649. if (IDOK == dwReturnStatus)
  650. goto ExecuteChange;
  651. // if user wants back, go back
  652. if (IDC_BACK == dwReturnStatus)
  653. goto Choose_Step1;
  654. // else, bail
  655. break;
  656. }
  657. case (BP_CONFIRM_OKCANCEL):
  658. {
  659. dwReturnStatus =
  660. ServicesDialogBoxParam(
  661. g_hInst,
  662. MAKEINTRESOURCE(IDD_ADVANCED_CONFIRM_M),
  663. (HWND)hDlg,
  664. DialogWaitForOKCancel,
  665. (LPARAM)pDialogArgs);
  666. // if user hits okay, execute
  667. if (IDOK == dwReturnStatus)
  668. goto ExecuteChange;
  669. // if user wants back, go back
  670. if (IDC_BACK == dwReturnStatus)
  671. goto Choose_Step1;
  672. // else, bail
  673. break;
  674. }
  675. case (BP_CONFIRM_NONE):
  676. {
  677. dwReturnStatus =
  678. ServicesDialogBoxParam(
  679. g_hInst,
  680. MAKEINTRESOURCE(IDD_ADVANCED_CONFIRM_L),
  681. (HWND)hDlg,
  682. DialogWaitForOKCancel,
  683. (LPARAM)pDialogArgs);
  684. // if user hits okay, execute
  685. if (IDOK == dwReturnStatus)
  686. goto ExecuteChange;
  687. // if user wants back, go back
  688. if (IDC_BACK == dwReturnStatus)
  689. goto Choose_Step1;
  690. // else, bail
  691. break;
  692. }
  693. default:
  694. break;
  695. }
  696. Ret:
  697. // free dyn alloced DialogArgs we aren't returning
  698. if (*(DlgArgs_Stack.ppszPWName))
  699. SSFree(*(DlgArgs_Stack.ppszPWName));
  700. if (*(DlgArgs_Stack.ppszPW))
  701. SSFree(*(DlgArgs_Stack.ppszPW));
  702. return FALSE;
  703. ExecuteChange:
  704. // free what we already know, point to newly alloc'ed pointers
  705. if (*(pDialogArgs->ppszPWName))
  706. SSFree(*(pDialogArgs->ppszPWName));
  707. *(pDialogArgs->ppszPWName) = szPWName_Stack;
  708. if (*(pDialogArgs->ppszPW))
  709. SSFree(*(pDialogArgs->ppszPW));
  710. *(pDialogArgs->ppszPW) = szPW_Stack;
  711. *(pDialogArgs->pdwPasswordOptions) = dwPasswordOptions_Stack;
  712. return TRUE;
  713. }
  714. ///////////////////////////////////////////////////////////////////////////
  715. ///////////////////////////////////////////////////////////////////////////
  716. // Actual Dialog Callbacks
  717. INT_PTR CALLBACK DialogAdvancedConfirmH(
  718. HWND hDlg, // handle to dialog box
  719. UINT message, // message
  720. WPARAM wParam, // first message parameter
  721. LPARAM lParam // second message parameter
  722. )
  723. {
  724. BOOL bSuccess = FALSE; // assume error
  725. PADVANCEDCONFIRM_DIALOGARGS pDialogArgs;
  726. BYTE rgb1[_MAX_PATH];
  727. LPWSTR pszMasterKey=NULL;
  728. char * szBuffer = NULL;
  729. DWORD dwCount;
  730. DWORD dwStatus;
  731. switch (message)
  732. {
  733. case WM_INITDIALOG:
  734. SetLastError( 0 ); // as per win32 documentation
  735. if(SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam) == 0) {
  736. if(GetLastError() != ERROR_SUCCESS) {
  737. EndDialog(hDlg, IDCANCEL);
  738. return FALSE;
  739. }
  740. }
  741. // lParam is struct
  742. pDialogArgs = (PADVANCEDCONFIRM_DIALOGARGS)lParam;
  743. // set dialog title
  744. SetWindowTextU(hDlg, pDialogArgs->szItemName);
  745. SetWindowTextU(GetDlgItem(hDlg, IDC_MESSAGE), g_PasswordCreate);
  746. // clear pwds
  747. SendDlgItemMessage(hDlg, IDC_PW_NAME, CB_RESETCONTENT, 0, 0);
  748. // Add known pwds
  749. for (dwCount=0; ;dwCount++)
  750. {
  751. if (PST_E_OK !=
  752. BPEnumMasterKeys(
  753. pDialogArgs->szUserName,
  754. dwCount,
  755. &pszMasterKey))
  756. break;
  757. // don't add non-editable passwords
  758. if (!FIsUserMasterKey(pszMasterKey))
  759. continue;
  760. // add this to the list and continue
  761. if (FIsWinNT())
  762. {
  763. SendDlgItemMessageW(hDlg, IDC_PW_NAME, CB_ADDSTRING, 0, (LPARAM) pszMasterKey);
  764. }
  765. #ifdef _M_IX86
  766. else
  767. {
  768. // only add if (! (NULL username && Windows password))
  769. if (
  770. (0 != wcscmp(pDialogArgs->szUserName, L"")) ||
  771. (0 != wcscmp(pszMasterKey, WSZ_PASSWORD_WINDOWS))
  772. )
  773. {
  774. MkMBStr(rgb1, _MAX_PATH, pszMasterKey, &szBuffer);
  775. SendDlgItemMessageA(hDlg, IDC_PW_NAME, CB_ADDSTRING, 0, (LPARAM) szBuffer);
  776. FreeMBStr(rgb1, szBuffer);
  777. }
  778. }
  779. #endif // _M_IX86
  780. SSFree(pszMasterKey);
  781. }
  782. // check to see if there are any items in listbox
  783. dwStatus = (DWORD) SendDlgItemMessageW(hDlg, IDC_PW_NAME, CB_GETCOUNT, 0, 0);
  784. if ((dwStatus == CB_ERR) || (dwStatus == 0))
  785. {
  786. // Listbox empty!
  787. // set default dialog selection to be "new password"
  788. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_SELEXISTING), FALSE);
  789. SendMessage(hDlg, WM_COMMAND, IDC_RADIO_DEFINENEW, 0); // as if user clicked NEW
  790. SendDlgItemMessage(hDlg, IDC_RADIO_DEFINENEW, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  791. }
  792. else
  793. {
  794. // Items do exist!
  795. // set default in dropdown
  796. if (FIsWinNT())
  797. dwStatus = (DWORD) SendDlgItemMessageW(hDlg, IDC_PW_NAME, CB_SELECTSTRING, (WORD)-1, (LPARAM) *(pDialogArgs->ppszPWName));
  798. #ifdef _M_IX86
  799. else
  800. {
  801. MkMBStr(rgb1, _MAX_PATH, (*pDialogArgs->ppszPWName), &szBuffer);
  802. dwStatus = SendDlgItemMessageA(hDlg, IDC_PW_NAME, CB_SELECTSTRING, (WORD)-1, (LONG) szBuffer);
  803. FreeMBStr(rgb1, szBuffer);
  804. }
  805. #endif // _M_IX86
  806. // if search failed, select first item in listbox
  807. if (dwStatus == CB_ERR)
  808. SendDlgItemMessage(hDlg, IDC_PW_NAME, CB_SETCURSEL, 0, 0);
  809. // set default dialog selection to be "existing pw"
  810. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_SELEXISTING), TRUE);
  811. SendMessage(hDlg, WM_COMMAND, IDC_RADIO_SELEXISTING, 0); // as if user clicked EXISTING
  812. SendDlgItemMessage(hDlg, IDC_RADIO_SELEXISTING, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  813. }
  814. return TRUE;
  815. case WM_COMMAND:
  816. {
  817. pDialogArgs = (PADVANCEDCONFIRM_DIALOGARGS)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  818. if(pDialogArgs == 0) break; // TODO: bail out
  819. switch (LOWORD(wParam))
  820. {
  821. case (IDOK):
  822. {
  823. if( *(pDialogArgs->ppszPWName) ) {
  824. SSFree(*(pDialogArgs->ppszPWName));
  825. *(pDialogArgs->ppszPWName) = NULL;
  826. }
  827. if(BST_CHECKED == SendDlgItemMessage(hDlg, IDC_RADIO_SELEXISTING, BM_GETCHECK, 0, 0))
  828. {
  829. WCHAR sz1[MAX_PW_LEN];
  830. DWORD cch1;
  831. // and get password name
  832. cch1 = GetDlgItemTextU(
  833. hDlg,
  834. IDC_PW_NAME,
  835. sz1,
  836. MAX_PW_LEN);
  837. *(pDialogArgs->ppszPWName) = (LPWSTR)SSAlloc((cch1+1)*sizeof(WCHAR));
  838. if(NULL != *(pDialogArgs->ppszPWName))
  839. {
  840. wcscpy(*(pDialogArgs->ppszPWName), sz1);
  841. }
  842. }
  843. else
  844. {
  845. LPWSTR* ppszPW;
  846. LPWSTR* ppszPWName;
  847. WCHAR sz1[MAX_PW_LEN];
  848. WCHAR sz2[MAX_PW_LEN];
  849. WCHAR szPWName[MAX_PW_LEN];
  850. DWORD cch1 = 0, cch2 = 0, cchPWName = 0;
  851. ppszPW = pDialogArgs->ppszPW;
  852. ppszPWName = pDialogArgs->ppszPWName;
  853. // don't stomp existing ppszPW/ppszPWName until we know we're okay
  854. cch1 = GetDlgItemTextU(
  855. hDlg,
  856. IDC_EDIT1,
  857. sz1,
  858. MAX_PW_LEN);
  859. cch2 = GetDlgItemTextU(
  860. hDlg,
  861. IDC_EDIT2,
  862. sz2,
  863. MAX_PW_LEN);
  864. if ( (cch1 != cch2) || (0 != wcscmp(sz1, sz2)) )
  865. {
  866. // this W implemented in both Win95 & NT!
  867. MessageBoxW(
  868. NULL, // hDlg,
  869. g_PasswordNoMatch,
  870. g_PasswordErrorDlgTitle,
  871. MB_OK | MB_ICONEXCLAMATION | MB_SERVICE_NOTIFICATION);
  872. SetWindowTextU(GetDlgItem(hDlg, IDC_EDIT1), WSZ_NULLSTRING);
  873. SetWindowTextU(GetDlgItem(hDlg, IDC_EDIT2), WSZ_NULLSTRING);
  874. goto cleanup;
  875. }
  876. cchPWName = GetDlgItemTextU(
  877. hDlg,
  878. IDC_PW_NEWNAME,
  879. szPWName,
  880. MAX_PW_LEN);
  881. if (cchPWName == 0)
  882. {
  883. // this W implemented in both Win95 & NT!
  884. MessageBoxW(
  885. NULL, // hDlg,
  886. g_PasswordMustName,
  887. g_PasswordErrorDlgTitle,
  888. MB_OK | MB_ICONEXCLAMATION | MB_SERVICE_NOTIFICATION);
  889. goto cleanup;
  890. }
  891. // trim spaces off rhs
  892. while(0 == memcmp(&szPWName[cchPWName-1], L" ", sizeof(WCHAR)))
  893. cchPWName--;
  894. szPWName[cchPWName] = L'\0';
  895. // try and create the pw entry
  896. if (!FInternal_CreateNewPasswordEntry(
  897. hDlg,
  898. pDialogArgs->szUserName,
  899. szPWName,
  900. sz1) )
  901. goto cleanup;
  902. // now bite it: save both
  903. SS_ASSERT(ppszPW != NULL);
  904. *ppszPW = (LPWSTR)SSAlloc( (cch1+1) * sizeof(WCHAR) );
  905. if(*ppszPW == NULL) goto cleanup;
  906. SS_ASSERT(ppszPWName != NULL);
  907. *ppszPWName = (LPWSTR)SSAlloc( (cchPWName + 1) * sizeof(WCHAR));
  908. if(*ppszPWName == NULL) goto cleanup;
  909. //
  910. // sfield: defer copying strings until we know everything succeeded.
  911. // this way, we don't have to zero these buffers if some
  912. // allocs + copies succeed, and others fail.
  913. //
  914. wcscpy(*ppszPW, sz1);
  915. wcscpy(*ppszPWName, szPWName);
  916. bSuccess = TRUE;
  917. cleanup:
  918. if(cch1) RtlSecureZeroMemory(sz1, cch1 * sizeof(WCHAR));
  919. if(cch2) RtlSecureZeroMemory(sz2, cch2 * sizeof(WCHAR));
  920. if(cchPWName) RtlSecureZeroMemory(szPWName, cchPWName * sizeof(WCHAR));
  921. if(!bSuccess)
  922. {
  923. // UNDONE: investigate freeing ppsz's on error here
  924. return FALSE;
  925. }
  926. break; // things went OK, just bail to EndDialog
  927. }
  928. } // IDOK
  929. // gray out options
  930. case IDC_RADIO_SELEXISTING:
  931. // set default selection to be "existing pw"
  932. EnableWindow(GetDlgItem(hDlg, IDC_PW_NAME), TRUE);
  933. EnableWindow(GetDlgItem(hDlg, IDC_PW_NEWNAME), FALSE);
  934. EnableWindow(GetDlgItem(hDlg, IDC_EDIT1), FALSE);
  935. EnableWindow(GetDlgItem(hDlg, IDC_EDIT2), FALSE);
  936. // set focus to first box under button
  937. SetFocus(GetDlgItem(hDlg, IDC_PW_NAME));
  938. break;
  939. case IDC_RADIO_DEFINENEW:
  940. // set default selection to be "existing pw"
  941. EnableWindow(GetDlgItem(hDlg, IDC_PW_NAME), FALSE);
  942. EnableWindow(GetDlgItem(hDlg, IDC_PW_NEWNAME), TRUE);
  943. EnableWindow(GetDlgItem(hDlg, IDC_EDIT1), TRUE);
  944. EnableWindow(GetDlgItem(hDlg, IDC_EDIT2), TRUE);
  945. // set focus to first box under button
  946. SetFocus(GetDlgItem(hDlg, IDC_PW_NEWNAME));
  947. break;
  948. default:
  949. break;
  950. }
  951. if (
  952. (LOWORD(wParam) == IDOK) ||
  953. (LOWORD(wParam) == IDCANCEL) ||
  954. (LOWORD(wParam) == IDC_BACK)
  955. )
  956. {
  957. EndDialog(hDlg, LOWORD(wParam));
  958. return TRUE;
  959. }
  960. break;
  961. }
  962. }
  963. return FALSE;
  964. }
  965. INT_PTR CALLBACK DialogWaitForOKCancel(
  966. HWND hDlg, // handle to dialog box
  967. UINT message, // message
  968. WPARAM wParam, // first message parameter
  969. LPARAM lParam // second message parameter
  970. )
  971. {
  972. PADVANCEDCONFIRM_DIALOGARGS pDialogArgs;
  973. switch (message)
  974. {
  975. case WM_INITDIALOG:
  976. {
  977. pDialogArgs = (PADVANCEDCONFIRM_DIALOGARGS)lParam;
  978. // set dialog title
  979. SetWindowTextU(hDlg, pDialogArgs->szItemName);
  980. }
  981. return TRUE;
  982. case WM_COMMAND:
  983. {
  984. if (
  985. (LOWORD(wParam) == IDOK) ||
  986. (LOWORD(wParam) == IDCANCEL) ||
  987. (LOWORD(wParam) == IDC_BACK)
  988. )
  989. {
  990. EndDialog(hDlg, LOWORD(wParam));
  991. return TRUE;
  992. }
  993. break;
  994. }
  995. default:
  996. break;
  997. }
  998. return FALSE;
  999. }
  1000. //
  1001. // make string LPTSTR types due to the way that the call back is prototyped
  1002. // when file is not compiled with #define UNICODE
  1003. // we should look at compiling everything with #define UNICODE later
  1004. //
  1005. BOOL
  1006. CALLBACK
  1007. FMyLoadIcon(
  1008. HINSTANCE hModule, // resource-module handle
  1009. LPCWSTR lpszType, // pointer to resource type
  1010. LPWSTR lpszName, // pointer to resource name
  1011. LONG_PTR lParam // application-defined parameter
  1012. )
  1013. {
  1014. if ((LPCWSTR)RT_GROUP_ICON != lpszType)
  1015. return TRUE; // keep looking, you fool!
  1016. //
  1017. // LoadIcon _may_ not work on Win95 if LOAD_LIBRARY_AS_DATAFILE was
  1018. // specified to LoadLibraryEx.
  1019. // We want to avoid calling DLL_PROCESS_ATTACH code for anything
  1020. // because that's a way to get arbitrary code to run in our address space
  1021. //
  1022. if(FIsWinNT()) {
  1023. //
  1024. // load the image via LoadImage, instead of LoadIcon, because
  1025. // LoadIcon does erroneous caching in some scenarios.
  1026. //
  1027. *(HICON*)lParam = (HICON)LoadImageW(
  1028. hModule,
  1029. lpszName,
  1030. IMAGE_ICON,
  1031. 0,
  1032. 0,
  1033. LR_DEFAULTCOLOR | LR_DEFAULTSIZE
  1034. );
  1035. return FALSE; // we've got at least one icon; stop!
  1036. } else {
  1037. //
  1038. // this more convoluted approach doesn't seem to work on NT, due
  1039. // to a limitation in CreateIconFromResource()
  1040. // This approach is good for Win95 because it allows us to use all
  1041. // Unicode API calls.
  1042. //
  1043. HRSRC hRsrc = NULL;
  1044. HGLOBAL hGlobal = NULL;
  1045. LPVOID lpRes = NULL;
  1046. int nID;
  1047. *(HICON*)lParam = NULL;
  1048. hRsrc = FindResourceW(hModule, lpszName, lpszType);
  1049. if(hRsrc == NULL)
  1050. return FALSE;
  1051. hGlobal = LoadResource(hModule, hRsrc);
  1052. if(hGlobal == NULL)
  1053. return FALSE;
  1054. lpRes = LockResource(hGlobal);
  1055. if(lpRes == NULL)
  1056. return FALSE;
  1057. nID = LookupIconIdFromDirectory( (PBYTE)lpRes, TRUE );
  1058. hRsrc = FindResourceW( hModule, MAKEINTRESOURCEW(nID), (LPCWSTR)RT_ICON );
  1059. if(hRsrc == NULL)
  1060. return FALSE;
  1061. hGlobal = LoadResource( hModule, hRsrc );
  1062. if(hGlobal == NULL)
  1063. return FALSE;
  1064. lpRes = LockResource(hGlobal);
  1065. if(lpRes == NULL)
  1066. return FALSE;
  1067. // Let the OS make us an icon
  1068. *(HICON*)lParam = CreateIconFromResource( (PBYTE)lpRes, SizeofResource(hModule, hRsrc), TRUE, 0x00030000 );
  1069. return FALSE;
  1070. }
  1071. }
  1072. INT_PTR CALLBACK DialogAccessDetails(
  1073. HWND hDlg, // handle to dialog box
  1074. UINT message, // message
  1075. WPARAM wParam, // first message parameter
  1076. LPARAM lParam // second message parameter
  1077. )
  1078. /*++
  1079. NOTENOTE
  1080. Anybody calling this dialog box routine should be imperonsating the client
  1081. associated with the call. This allows access to icon and any on-disk
  1082. resources to occur in the security context of the client.
  1083. --*/
  1084. {
  1085. BOOL fDlgEnterPassword;
  1086. PPW_DIALOG_ARGS pDialogArgs;
  1087. // TODO this function needs more cleanup
  1088. switch (message)
  1089. {
  1090. case WM_INITDIALOG:
  1091. {
  1092. BOOL fImpersonated;
  1093. SetLastError( 0 ); // as per win32 documentation
  1094. if(SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam) == 0) {
  1095. if(GetLastError() != ERROR_SUCCESS) {
  1096. EndDialog(hDlg, IDCANCEL);
  1097. return FALSE;
  1098. }
  1099. }
  1100. // lParam is struct
  1101. pDialogArgs = (PPW_DIALOG_ARGS)lParam;
  1102. // init static vars
  1103. pDialogArgs->hMyDC = GetDC(hDlg);
  1104. // set dialog title
  1105. SetWindowTextU(hDlg, pDialogArgs->szItemName);
  1106. //
  1107. // set application name, path
  1108. //
  1109. SetWindowTextU(GetDlgItem(hDlg,IDC_APP_PATH), pDialogArgs->szAppName);
  1110. SetWindowTextU(GetDlgItem(hDlg, IDC_APP_NAME), L"");
  1111. // set item name, type
  1112. SetWindowTextU(GetDlgItem(hDlg, IDC_ITEM_NAME), pDialogArgs->szItemName);
  1113. SetWindowTextU(GetDlgItem(hDlg, IDC_ITEM_TYPE), pDialogArgs->szItemType);
  1114. // set messages
  1115. SetWindowTextU(GetDlgItem(hDlg, IDC_MESSAGE), g_ItemDetailsBannerMessage);
  1116. // set access description
  1117. SetWindowTextU(GetDlgItem(hDlg, IDC_ACCESS_TYPE), pDialogArgs->szAccess);
  1118. HWND hIconBox;
  1119. RECT rect;
  1120. POINT point;
  1121. hIconBox = GetDlgItem(hDlg, IDC_ICONBOX);
  1122. if ((NULL != pDialogArgs) &&
  1123. GetWindowRect(hIconBox, &rect) &&
  1124. (pDialogArgs->hMyDC != NULL) &&
  1125. GetDCOrgEx(pDialogArgs->hMyDC, &point) ) // rect on window, window on screen
  1126. {
  1127. // need pos of icon on DC: subtract GetWindowRect()-GetDCOrgEx()
  1128. pDialogArgs->xIconPos = rect.left - point.x;
  1129. pDialogArgs->yIconPos = rect.top - point.y;
  1130. }
  1131. // update the changable data view
  1132. SendMessage(hDlg, WM_COMMAND, (WORD)DLG_UPDATE_DATA, 0);
  1133. return (TRUE);
  1134. } // WM_INITDIALOG
  1135. case WM_PAINT:
  1136. {
  1137. HDC hMyDC;
  1138. HICON hIcon;
  1139. int xIconPos, yIconPos;
  1140. pDialogArgs = (PPW_DIALOG_ARGS)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  1141. if(pDialogArgs == 0) break; // TODO: bail out
  1142. hMyDC = pDialogArgs->hMyDC;
  1143. hIcon = pDialogArgs->hIcon;
  1144. xIconPos = pDialogArgs->xIconPos;
  1145. yIconPos = pDialogArgs->yIconPos;
  1146. if ((hMyDC != NULL) && (hIcon != NULL) && (xIconPos != 0) && (yIconPos != 0))
  1147. DrawIcon(hMyDC, xIconPos, yIconPos, hIcon);
  1148. return (0);
  1149. } // WM_PAINT
  1150. case WM_COMMAND:
  1151. pDialogArgs = (PPW_DIALOG_ARGS)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  1152. if(pDialogArgs == 0) break; // TODO: bail out
  1153. switch (LOWORD(wParam))
  1154. {
  1155. case IDOK:
  1156. break;
  1157. default:
  1158. break;
  1159. } // switch
  1160. if (
  1161. (LOWORD(wParam) == IDOK) ||
  1162. (LOWORD(wParam) == IDCANCEL)
  1163. )
  1164. {
  1165. ReleaseDC(hDlg, pDialogArgs->hMyDC);
  1166. EndDialog(hDlg, LOWORD(wParam));
  1167. return TRUE;
  1168. }
  1169. break;
  1170. } // switch (message)
  1171. return FALSE;
  1172. }
  1173. INT_PTR CALLBACK DialogSimplifiedPasswordConfirm(
  1174. HWND hDlg, // handle to dialog box
  1175. UINT message, // message
  1176. WPARAM wParam, // first message parameter
  1177. LPARAM lParam // second message parameter
  1178. )
  1179. /*++
  1180. NOTENOTE
  1181. Anybody calling this dialog box routine should be imperonsating the client
  1182. associated with the call. This allows access to icon and any on-disk
  1183. resources to occur in the security context of the client.
  1184. --*/
  1185. {
  1186. BOOL fDlgEnterPassword;
  1187. PPW_DIALOG_ARGS pDialogArgs;
  1188. // TODO this function needs more cleanup
  1189. switch (message)
  1190. {
  1191. case WM_INITDIALOG:
  1192. {
  1193. BOOL fImpersonated;
  1194. SetLastError( 0 ); // as per win32 documentation
  1195. if(SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam) == 0) {
  1196. if(GetLastError() != ERROR_SUCCESS) {
  1197. EndDialog(hDlg, IDCANCEL);
  1198. return FALSE;
  1199. }
  1200. }
  1201. // lParam is struct
  1202. pDialogArgs = (PPW_DIALOG_ARGS)lParam;
  1203. // init static vars
  1204. pDialogArgs->hMyDC = GetDC(hDlg);
  1205. // Messages to User
  1206. // Dialog Bar = item name
  1207. SetWindowTextU(hDlg, pDialogArgs->szItemName);
  1208. // application friendly name
  1209. SetWindowTextU(GetDlgItem(hDlg, IDC_MESSAGE), L"");
  1210. // app msg
  1211. SetWindowTextU(GetDlgItem(hDlg, IDC_APP_MSG), pDialogArgs->szPrompt);
  1212. // update the changable data view
  1213. SendMessage(hDlg, WM_COMMAND, (WORD)DLG_UPDATE_DATA, 0);
  1214. //
  1215. // if migration disposition, bail out of UI now for OK-Cancel style.
  1216. //
  1217. if( (pDialogArgs->dwFlags & PST_NO_UI_MIGRATION) &&
  1218. ((*pDialogArgs->pdwPasswordOptions) & BP_CONFIRM_OKCANCEL)
  1219. )
  1220. {
  1221. SendMessage(hDlg, WM_COMMAND, IDOK, 0);
  1222. }
  1223. return (TRUE);
  1224. } // WM_INITDIALOG
  1225. case WM_PAINT:
  1226. {
  1227. HDC hMyDC;
  1228. HICON hIcon;
  1229. int xIconPos, yIconPos;
  1230. pDialogArgs = (PPW_DIALOG_ARGS)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  1231. if(pDialogArgs == 0) break; // TODO: bail out
  1232. hMyDC = pDialogArgs->hMyDC;
  1233. hIcon = pDialogArgs->hIcon;
  1234. xIconPos = pDialogArgs->xIconPos;
  1235. yIconPos = pDialogArgs->yIconPos;
  1236. if ((hMyDC != NULL) && (hIcon != NULL) && (xIconPos != 0) && (yIconPos != 0))
  1237. DrawIcon(hMyDC, xIconPos, yIconPos, hIcon);
  1238. return (0);
  1239. } // WM_PAINT
  1240. case WM_COMMAND:
  1241. PLUID pluidAuthID;
  1242. pDialogArgs = (PPW_DIALOG_ARGS)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  1243. if(pDialogArgs == 0) break; // TODO: bail out
  1244. pluidAuthID = &(pDialogArgs->luidAuthID);
  1245. switch (LOWORD(wParam))
  1246. {
  1247. case IDOK:
  1248. if(NULL == g_pCUAList)
  1249. {
  1250. return FALSE;
  1251. }
  1252. if (*(pDialogArgs->pdwPasswordOptions) == BP_CONFIRM_PASSWORDUI)
  1253. {
  1254. WCHAR sz1[MAX_PW_LEN];
  1255. DWORD cch1;
  1256. BOOL fUserSaysCache;
  1257. if( g_fAllowCachePW )
  1258. {
  1259. fUserSaysCache = (BST_CHECKED == SendMessage(GetDlgItem(hDlg, IDC_CACHEPW), BM_GETCHECK, 0, 0));
  1260. } else {
  1261. fUserSaysCache = FALSE;
  1262. }
  1263. // get password
  1264. cch1 = GetDlgItemTextU(
  1265. hDlg,
  1266. IDC_EDIT1,
  1267. sz1,
  1268. MAX_PW_LEN);
  1269. //
  1270. // compute hashs from scratch
  1271. //
  1272. if (!MyGetPwdHash(sz1, pDialogArgs->rgbPwd))
  1273. break;
  1274. if (!MyGetPwdHashEx(sz1, pDialogArgs->rgbPwdLowerCase, TRUE))
  1275. break;
  1276. // query cache for password
  1277. if (FIsCachedPassword(pDialogArgs->szUserName, *pDialogArgs->ppszPWName, pluidAuthID))
  1278. {
  1279. // find cached pwd
  1280. UACACHE_LIST_ITEM li, *pli;
  1281. CreateUACacheListItem(
  1282. &li,
  1283. pDialogArgs->szUserName,
  1284. *pDialogArgs->ppszPWName,
  1285. pluidAuthID);
  1286. g_pCUAList->LockList();
  1287. // find in list
  1288. if (NULL == (pli = g_pCUAList->SearchList(&li))) {
  1289. g_pCUAList->UnlockList();
  1290. break;
  1291. }
  1292. // change behavior based on if user tampered with pwd
  1293. if (0 == wcscmp(WSZ_PASSWORD_CHANGE_DETECT_TOKEN, sz1))
  1294. {
  1295. // no; copy cached password to outbuf
  1296. CopyMemory(pDialogArgs->rgbPwd, pli->rgbPwd, A_SHA_DIGEST_LEN);
  1297. // no; copy cached password to outbuf
  1298. CopyMemory(pDialogArgs->rgbPwdLowerCase, pli->rgbPwdLowerCase, A_SHA_DIGEST_LEN);
  1299. }
  1300. else
  1301. {
  1302. // yes: overwrite cached entry with user-entered
  1303. CopyMemory(pli->rgbPwd, pDialogArgs->rgbPwd, A_SHA_DIGEST_LEN);
  1304. // yes: overwrite cached entry with user-entered
  1305. CopyMemory(pli->rgbPwdLowerCase, pDialogArgs->rgbPwdLowerCase, A_SHA_DIGEST_LEN);
  1306. }
  1307. g_pCUAList->UnlockList();
  1308. if (!fUserSaysCache)
  1309. {
  1310. // is already cached, and don't want it to be used
  1311. // remove from cache
  1312. g_pCUAList->DelFromList(&li);
  1313. }
  1314. }
  1315. else
  1316. {
  1317. if (fUserSaysCache)
  1318. {
  1319. // isn't already cached, and want it to be used
  1320. // create element
  1321. UACACHE_LIST_ITEM* pli = (UACACHE_LIST_ITEM*) SSAlloc(sizeof(UACACHE_LIST_ITEM));
  1322. CreateUACacheListItem(
  1323. pli,
  1324. NULL,
  1325. NULL,
  1326. pluidAuthID);
  1327. pli->szUserName = (LPWSTR)SSAlloc(WSZ_BYTECOUNT(pDialogArgs->szUserName));
  1328. wcscpy(pli->szUserName, pDialogArgs->szUserName);
  1329. pli->szMKName = (LPWSTR)SSAlloc(WSZ_BYTECOUNT(*pDialogArgs->ppszPWName));
  1330. wcscpy(pli->szMKName, *pDialogArgs->ppszPWName);
  1331. CopyMemory(pli->rgbPwd, pDialogArgs->rgbPwd, A_SHA_DIGEST_LEN);
  1332. CopyMemory(pli->rgbPwdLowerCase, pDialogArgs->rgbPwdLowerCase, A_SHA_DIGEST_LEN);
  1333. // add to list
  1334. g_pCUAList->AddToList(pli);
  1335. }
  1336. else
  1337. {
  1338. // isn't already cached, and don't want it to be used
  1339. }
  1340. }
  1341. RtlSecureZeroMemory(sz1, WSZ_BYTECOUNT(sz1));
  1342. }
  1343. // else
  1344. break;
  1345. case IDC_ADVANCED:
  1346. {
  1347. // make copy so static members (x, y, hIcon) don't get stomped
  1348. PW_DIALOG_ARGS DetailDlgParms;
  1349. CopyMemory(&DetailDlgParms, pDialogArgs, sizeof(PW_DIALOG_ARGS));
  1350. ServicesDialogBoxParam(
  1351. g_hInst,
  1352. MAKEINTRESOURCE(IDD_ITEM_DETAILS),
  1353. (HWND)hDlg,
  1354. DialogAccessDetails,
  1355. (LPARAM)&DetailDlgParms);
  1356. // update the changable data view
  1357. SendMessage(hDlg, WM_COMMAND, (WORD)DLG_UPDATE_DATA, 0);
  1358. }
  1359. break;
  1360. case IDC_CHANGE_SECURITY:
  1361. {
  1362. ADVANCEDCONFIRM_DIALOGARGS DialogArgs = {pDialogArgs->szUserName, pDialogArgs->ppszPWName, pDialogArgs->ppszPW, pDialogArgs->pdwPasswordOptions, pDialogArgs->szItemName};
  1363. ChooseSecurityWizard(hDlg, &DialogArgs);
  1364. // commit changes
  1365. SendMessage(hDlg, WM_COMMAND, (WORD)DLG_UPDATE_DATA, 0);
  1366. break;
  1367. }
  1368. case DLG_UPDATE_DATA:
  1369. {
  1370. WCHAR szDialogMessage[MAX_STRING_RSC_SIZE] = L"\0";
  1371. // show or hide pwd entry box?
  1372. fDlgEnterPassword = (*(pDialogArgs->pdwPasswordOptions) == BP_CONFIRM_PASSWORDUI);
  1373. if (fDlgEnterPassword)
  1374. {
  1375. //
  1376. // comment out the following because we don't use %ls format string at the moment.
  1377. //
  1378. wcscpy(szDialogMessage, g_PWPromptPrefix);
  1379. wcscat(szDialogMessage, *(pDialogArgs->ppszPWName));
  1380. wcscat(szDialogMessage, g_PWPromptSuffix);
  1381. SetWindowTextU(GetDlgItem(hDlg, IDC_LABEL_EDIT1), szDialogMessage);
  1382. // we should not hide these windows
  1383. ShowWindow(GetDlgItem(hDlg, IDC_EDIT1), SW_SHOW);
  1384. EnableWindow(GetDlgItem(hDlg, IDC_EDIT1), TRUE);
  1385. ShowWindow(GetDlgItem(hDlg, IDC_LABEL_EDIT1), SW_SHOW);
  1386. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_EDIT1), TRUE);
  1387. if( pDialogArgs->fAllowConfirmChange &&
  1388. g_fAllowCachePW )
  1389. {
  1390. // show or hide "cache this password" button
  1391. ShowWindow(GetDlgItem(hDlg, IDC_CACHEPW), SW_SHOW );
  1392. EnableWindow(GetDlgItem(hDlg, IDC_CACHEPW), TRUE );
  1393. } else {
  1394. ShowWindow(GetDlgItem(hDlg, IDC_CACHEPW), SW_HIDE );
  1395. EnableWindow(GetDlgItem(hDlg, IDC_CACHEPW), FALSE );
  1396. }
  1397. // put untypable token into pwd field
  1398. if (FIsCachedPassword(pDialogArgs->szUserName, *pDialogArgs->ppszPWName, pluidAuthID))
  1399. SetWindowTextU(GetDlgItem(hDlg, IDC_EDIT1), WSZ_PASSWORD_CHANGE_DETECT_TOKEN);
  1400. // show if this password is cached
  1401. SendMessage(GetDlgItem(hDlg, IDC_CACHEPW), BM_SETCHECK, (WPARAM)(FIsCachedPassword(pDialogArgs->szUserName, *pDialogArgs->ppszPWName, pluidAuthID)), 0);
  1402. SetFocus(GetDlgItem(hDlg, IDC_EDIT1));
  1403. }
  1404. else
  1405. {
  1406. // hide pw
  1407. ShowWindow(GetDlgItem(hDlg, IDC_EDIT1), SW_HIDE);
  1408. ShowWindow(GetDlgItem(hDlg, IDC_LABEL_EDIT1), SW_HIDE);
  1409. EnableWindow(GetDlgItem(hDlg, IDC_EDIT1), FALSE);
  1410. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_EDIT1), FALSE);
  1411. ShowWindow(GetDlgItem(hDlg, IDC_CACHEPW), SW_HIDE);
  1412. EnableWindow(GetDlgItem(hDlg, IDC_CACHEPW), FALSE);
  1413. }
  1414. // show or hide "change security" button
  1415. ShowWindow(GetDlgItem(hDlg, IDC_CHANGE_SECURITY), ((pDialogArgs->fAllowConfirmChange) ? SW_SHOW : SW_HIDE));
  1416. EnableWindow(GetDlgItem(hDlg, IDC_CHANGE_SECURITY), ((pDialogArgs->fAllowConfirmChange) ? TRUE : FALSE));
  1417. // show or hide "details" button
  1418. ShowWindow(GetDlgItem(hDlg, IDC_ADVANCED), ((pDialogArgs->fAllowConfirmChange) ? SW_SHOW : SW_HIDE));
  1419. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED), ((pDialogArgs->fAllowConfirmChange) ? TRUE : FALSE));
  1420. // show or hide "level currently set to *"
  1421. ShowWindow(GetDlgItem(hDlg, IDC_SEC_PREFIX), ((pDialogArgs->fAllowConfirmChange) ? SW_SHOW : SW_HIDE));
  1422. ShowWindow(GetDlgItem(hDlg, IDC_SEC_LEVEL), ((pDialogArgs->fAllowConfirmChange) ? SW_SHOW : SW_HIDE));
  1423. // jam the current security setting
  1424. switch(*pDialogArgs->pdwPasswordOptions)
  1425. {
  1426. case BP_CONFIRM_PASSWORDUI:
  1427. SetWindowTextU(GetDlgItem(hDlg, IDC_SEC_LEVEL), g_PromptHighSecurity);
  1428. break;
  1429. case BP_CONFIRM_OKCANCEL:
  1430. SetWindowTextU(GetDlgItem(hDlg, IDC_SEC_LEVEL), g_PromptMedSecurity);
  1431. break;
  1432. case BP_CONFIRM_NONE:
  1433. SetWindowTextU(GetDlgItem(hDlg, IDC_SEC_LEVEL), g_PromptLowSecurity);
  1434. break;
  1435. }
  1436. }
  1437. break;
  1438. default:
  1439. break;
  1440. } // switch
  1441. if (
  1442. (LOWORD(wParam) == IDOK) ||
  1443. (LOWORD(wParam) == IDCANCEL)
  1444. )
  1445. {
  1446. ReleaseDC(hDlg, pDialogArgs->hMyDC);
  1447. EndDialog(hDlg, LOWORD(wParam));
  1448. return TRUE;
  1449. }
  1450. break;
  1451. } // switch (message)
  1452. return FALSE;
  1453. }
  1454. INT_PTR CALLBACK DialogSetSecurityLevel(
  1455. HWND hDlg, // handle to dialog box
  1456. UINT message, // message
  1457. WPARAM wParam, // first message parameter
  1458. LPARAM lParam // second message parameter
  1459. )
  1460. {
  1461. PADVANCEDCONFIRM_DIALOGARGS pDialogArgs;
  1462. BYTE rgb1[_MAX_PATH];
  1463. LPWSTR pszMasterKey=NULL;
  1464. char * szBuffer = NULL;
  1465. switch (message)
  1466. {
  1467. case WM_INITDIALOG:
  1468. {
  1469. SetLastError( 0 ); // as per win32 documentation
  1470. if(SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam) == 0) {
  1471. if(GetLastError() != ERROR_SUCCESS) {
  1472. EndDialog(hDlg, IDCANCEL);
  1473. return FALSE;
  1474. }
  1475. }
  1476. // lParam is PADVANCEDCONFIRM_DIALOGARGS
  1477. pDialogArgs = (PADVANCEDCONFIRM_DIALOGARGS)lParam;
  1478. // set the dialog title
  1479. SetWindowTextU(hDlg, pDialogArgs->szItemName);
  1480. switch(*(pDialogArgs->pdwPasswordOptions))
  1481. {
  1482. case BP_CONFIRM_NONE:
  1483. SendDlgItemMessage(hDlg, IDC_RADIO_NOCONFIRM, BM_SETCHECK, BST_CHECKED, 0);
  1484. SendMessage(hDlg, WM_COMMAND, (WORD)IDC_RADIO_NOCONFIRM, 0);
  1485. break;
  1486. case BP_CONFIRM_OKCANCEL:
  1487. SendDlgItemMessage(hDlg, IDC_RADIO_OKCANCEL, BM_SETCHECK, BST_CHECKED, 0);
  1488. SendMessage(hDlg, WM_COMMAND, (WORD)IDC_RADIO_OKCANCEL, 0);
  1489. break;
  1490. case BP_CONFIRM_PASSWORDUI:
  1491. default:
  1492. SendDlgItemMessage(hDlg, IDC_RADIO_ASSIGNPW, BM_SETCHECK, BST_CHECKED, 0);
  1493. SendMessage(hDlg, WM_COMMAND, (WORD)IDC_RADIO_ASSIGNPW, 0);
  1494. break;
  1495. }
  1496. return TRUE;
  1497. } // WM_INITDIALOG
  1498. case WM_COMMAND:
  1499. {
  1500. LPWSTR* ppszPW;
  1501. BOOL bSuccess = FALSE;
  1502. switch (LOWORD(wParam))
  1503. {
  1504. case IDC_NEXT:
  1505. case IDOK:
  1506. {
  1507. pDialogArgs = (PADVANCEDCONFIRM_DIALOGARGS)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  1508. if(pDialogArgs == 0) break; // TODO: bail out
  1509. // modify *(pDialogArgs->pdwPasswordOptions);
  1510. if (BST_CHECKED == SendDlgItemMessage(hDlg, IDC_RADIO_ASSIGNPW, BM_GETCHECK, 0, 0))
  1511. {
  1512. *(pDialogArgs->pdwPasswordOptions) = BP_CONFIRM_PASSWORDUI;
  1513. }
  1514. else
  1515. if (BST_CHECKED == SendDlgItemMessage(hDlg, IDC_RADIO_NOCONFIRM, BM_GETCHECK, 0, 0))
  1516. *(pDialogArgs->pdwPasswordOptions) = BP_CONFIRM_NONE;
  1517. else
  1518. *(pDialogArgs->pdwPasswordOptions) = BP_CONFIRM_OKCANCEL;
  1519. if (BP_CONFIRM_PASSWORDUI != *(pDialogArgs->pdwPasswordOptions))
  1520. {
  1521. *(pDialogArgs->ppszPWName) = (LPWSTR)SSAlloc(sizeof(WSZ_PASSWORD_WINDOWS));
  1522. if(*(pDialogArgs->ppszPWName) != NULL)
  1523. {
  1524. wcscpy(*(pDialogArgs->ppszPWName), WSZ_PASSWORD_WINDOWS);
  1525. }
  1526. }
  1527. break;
  1528. }
  1529. default:
  1530. break;
  1531. }
  1532. if (
  1533. (LOWORD(wParam) == IDOK) ||
  1534. (LOWORD(wParam) == IDCANCEL) ||
  1535. (LOWORD(wParam) == IDC_NEXT)
  1536. )
  1537. {
  1538. EndDialog(hDlg, LOWORD(wParam));
  1539. return bSuccess;
  1540. }
  1541. } // WM_COMMAND
  1542. default:
  1543. return FALSE;
  1544. }
  1545. }