Source code of Windows XP (NT5)
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.

1428 lines
32 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. wizdlg.c
  5. Abstract:
  6. This module implements the dialog box procedures needed for the Win9x side
  7. of the upgrade.
  8. Author:
  9. Jim Schmidt (jimschm) 17-Mar-1997
  10. Revision History:
  11. jimschm 29-Sep-1998 Domain credentials dialog
  12. jimschm 24-Dec-1997 Added ChangeNameDlg functionality
  13. --*/
  14. #include "pch.h"
  15. #include "uip.h"
  16. #include <commdlg.h>
  17. //
  18. // Globals
  19. //
  20. HWND g_UiTextViewCtrl;
  21. #define USER_NAME_SIZE (MAX_USER_NAME + 1 + MAX_SERVER_NAME)
  22. //
  23. // Local function prototypes
  24. //
  25. VOID
  26. AppendMigDllNameToList (
  27. IN PCTSTR strName
  28. );
  29. LONG
  30. SearchForDrivers (
  31. IN HWND Parent,
  32. IN PCTSTR SearchPathStr,
  33. OUT BOOL *DriversFound
  34. );
  35. BOOL
  36. CALLBACK
  37. pChangeNameDlgProc (
  38. IN HWND hdlg,
  39. IN UINT uMsg,
  40. IN WPARAM wParam,
  41. IN LPARAM lParam
  42. );
  43. BOOL
  44. CALLBACK
  45. pCredentialsDlgProc (
  46. IN HWND hdlg,
  47. IN UINT uMsg,
  48. IN WPARAM wParam,
  49. IN LPARAM lParam
  50. );
  51. //
  52. // Implementation
  53. //
  54. VOID
  55. UI_InsertItemsIntoListCtrl (
  56. IN HWND ListCtrl,
  57. IN INT Item,
  58. IN LPTSTR ItemStrs, // tab-separated list
  59. IN LPARAM lParam
  60. )
  61. /*++
  62. This function is not used, but is useful and we should keep it around
  63. just in case a list control is used later.
  64. Routine Description:
  65. Parses a string that has tab characters separating columns and inserts
  66. the string into a multiple column list control.
  67. Arguments:
  68. ListCtrl - Specifies the handle to the list control
  69. Item - Specifies the position where the string is insert in the list
  70. ItemStrs - Specifies a tab-delimited list of strings to be inserted. The
  71. string is split at the tabs. The tabs are temporarilty replaced
  72. with nuls but the string is not changed.
  73. lParam - Specifies a value to associate with the list item.
  74. Return Value:
  75. none
  76. --*/
  77. {
  78. LPTSTR Start, End;
  79. TCHAR tc;
  80. LV_ITEM item;
  81. int i;
  82. ZeroMemory (&item, sizeof (item));
  83. item.iItem = Item;
  84. item.lParam = lParam;
  85. Start = (LPTSTR) ItemStrs;
  86. i = 0;
  87. do {
  88. End = _tcschr (Start, TEXT('\t'));
  89. if (!End)
  90. End = GetEndOfString (Start);
  91. tc = (TCHAR) _tcsnextc (End);
  92. *End = 0;
  93. item.iSubItem = i;
  94. i++;
  95. item.pszText = Start;
  96. if (i != 1) {
  97. item.mask = LVIF_TEXT;
  98. ListView_SetItem (ListCtrl, &item);
  99. }
  100. else {
  101. item.mask = LVIF_TEXT|LVIF_PARAM;
  102. Item = ListView_InsertItem (ListCtrl, &item);
  103. item.iItem = Item;
  104. }
  105. Start = _tcsinc (End);
  106. *End = tc;
  107. } while (tc);
  108. }
  109. //
  110. // Warning dialog proc
  111. //
  112. BOOL
  113. CALLBACK
  114. WarningProc (
  115. HWND hdlg,
  116. UINT uMsg,
  117. WPARAM wParam,
  118. LPARAM lParam
  119. )
  120. {
  121. switch (uMsg) {
  122. case WM_INITDIALOG:
  123. CenterWindow (hdlg, GetDesktopWindow());
  124. return FALSE;
  125. case WM_COMMAND:
  126. EndDialog (hdlg, LOWORD (wParam));
  127. break;
  128. }
  129. return FALSE;
  130. }
  131. LPARAM
  132. WarningDlg (
  133. HWND Parent
  134. )
  135. {
  136. return DialogBox (g_hInst, MAKEINTRESOURCE(IDD_CONSIDERING_DLG), Parent, WarningProc);
  137. }
  138. LPARAM
  139. SoftBlockDlg (
  140. HWND Parent
  141. )
  142. {
  143. return DialogBox (g_hInst, MAKEINTRESOURCE(IDD_APPBLOCK_DLG), Parent, WarningProc);
  144. }
  145. LPARAM
  146. IncompatibleDevicesDlg (
  147. HWND Parent
  148. )
  149. {
  150. return DialogBox (g_hInst, MAKEINTRESOURCE(IDD_INCOMPATIBLE_DEVICES), Parent, WarningProc);
  151. }
  152. BOOL
  153. CALLBACK
  154. DiskSpaceProc (
  155. HWND hdlg,
  156. UINT uMsg,
  157. WPARAM wParam,
  158. LPARAM lParam
  159. )
  160. {
  161. BOOL dialogDone = FALSE;
  162. static PCTSTR message = NULL;
  163. switch (uMsg) {
  164. case WM_INITDIALOG:
  165. CenterWindow (hdlg, GetDesktopWindow());
  166. message = GetNotEnoughSpaceMessage ();
  167. SetWindowText (GetDlgItem (hdlg, IDC_SPACE_NEEDED), message);
  168. return FALSE;
  169. case WM_COMMAND:
  170. dialogDone = TRUE;
  171. break;
  172. }
  173. if (dialogDone) {
  174. //
  175. // free resources.
  176. //
  177. FreeStringResource (message);
  178. EndDialog (hdlg, LOWORD (wParam));
  179. }
  180. return FALSE;
  181. }
  182. LPARAM
  183. DiskSpaceDlg (
  184. IN HWND Parent
  185. )
  186. {
  187. return DialogBox (g_hInst, MAKEINTRESOURCE(IDD_DISKSPACE_DLG), Parent, DiskSpaceProc);
  188. }
  189. //
  190. // Results dialog proc
  191. //
  192. #define IDC_TEXTVIEW 5101
  193. #define WMX_FILL_TEXTVIEW (WM_USER+512)
  194. DWORD
  195. WINAPI
  196. pSearchForDrivers (
  197. PVOID Param
  198. )
  199. {
  200. PSEARCHING_THREAD_DATA Data;
  201. BOOL b;
  202. Data = (PSEARCHING_THREAD_DATA) Param;
  203. Data->CancelEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
  204. if (!Data->CancelEvent) {
  205. DEBUGMSG ((DBG_ERROR, "pSearchForMigrationDlls: Could not create cancel event"));
  206. return 0;
  207. }
  208. b = ScanPathForDrivers (
  209. Data->hdlg,
  210. Data->SearchStr,
  211. g_TempDir,
  212. Data->CancelEvent
  213. );
  214. PostMessage (Data->hdlg, WMX_THREAD_DONE, 0, GetLastError());
  215. Data->ActiveMatches = b ? 1 : 0;
  216. Data->MatchFound = b;
  217. return 0;
  218. }
  219. BOOL
  220. CALLBACK
  221. UpgradeModuleDlgProc (
  222. HWND hdlg,
  223. UINT uMsg,
  224. WPARAM wParam,
  225. LPARAM lParam
  226. )
  227. {
  228. BROWSEINFO bi;
  229. REGVALUE_ENUM eValue;
  230. MIGDLL_ENUM e;
  231. RECT ListRect;
  232. LPITEMIDLIST ItemIdList;
  233. HKEY Key;
  234. HWND List;
  235. PCTSTR Data;
  236. TCHAR SearchPathStr[MAX_TCHAR_PATH];
  237. TCHAR Node[MEMDB_MAX];
  238. LONG Index;
  239. LONG TopIndex;
  240. LONG ItemData;
  241. UINT ActiveModulesFound;
  242. BOOL OneModuleFound;
  243. UINT Length;
  244. LONG rc;
  245. switch (uMsg) {
  246. case WM_INITDIALOG:
  247. SendMessage (hdlg, WMX_UPDATE_LIST, 0, 0);
  248. return FALSE;
  249. case WMX_UPDATE_LIST:
  250. //
  251. // Enumerate all migration DLLs and shove the program ID in list box
  252. //
  253. List = GetDlgItem (hdlg, IDC_LIST);
  254. SendMessage (List, LB_RESETCONTENT, 0, 0);
  255. EnableWindow (GetDlgItem (hdlg, IDC_REMOVE), FALSE);
  256. if (EnumFirstMigrationDll (&e)) {
  257. EnableWindow (List, TRUE);
  258. do {
  259. Index = SendMessage (List, LB_ADDSTRING, 0, (LPARAM) e.ProductId);
  260. SendMessage (List, LB_SETITEMDATA, Index, (LPARAM) e.Id);
  261. } while (EnumNextMigrationDll (&e));
  262. }
  263. //
  264. // Enumerate all migration DLLs pre-loaded in the registry, and add them
  265. // to the list box if they haven't been "removed" by the user
  266. //
  267. Key = OpenRegKeyStr (S_PREINSTALLED_MIGRATION_DLLS);
  268. if (Key) {
  269. if (EnumFirstRegValue (&eValue, Key)) {
  270. do {
  271. //
  272. // Suppressed? If not, add to list.
  273. //
  274. MemDbBuildKey (
  275. Node,
  276. MEMDB_CATEGORY_DISABLED_MIGDLLS,
  277. NULL, // no item
  278. NULL, // no field
  279. eValue.ValueName
  280. );
  281. if (!MemDbGetValue (Node, NULL)) {
  282. Index = SendMessage (List, LB_ADDSTRING, 0, (LPARAM) eValue.ValueName);
  283. SendMessage (List, LB_SETITEMDATA, Index, (LPARAM) REGISTRY_DLL);
  284. }
  285. } while (EnumNextRegValue (&eValue));
  286. }
  287. CloseRegKey (Key);
  288. }
  289. if (SendMessage (List, LB_GETCOUNT, 0, 0) == 0) {
  290. EnableWindow (List, FALSE);
  291. }
  292. return TRUE;
  293. case WM_COMMAND:
  294. switch (LOWORD (wParam)) {
  295. case IDOK:
  296. case IDCANCEL:
  297. EndDialog (hdlg, IDOK);
  298. return TRUE;
  299. case IDC_LIST:
  300. if (HIWORD (wParam) == LBN_SELCHANGE) {
  301. EnableWindow (GetDlgItem (hdlg, IDC_REMOVE), TRUE);
  302. }
  303. break;
  304. case IDC_REMOVE:
  305. //
  306. // Delete item from internal memory structure
  307. // or keep registry-loaded DLL from running
  308. //
  309. List = GetDlgItem (hdlg, IDC_LIST);
  310. SendMessage (List, WM_SETREDRAW, FALSE, 0);
  311. Index = SendMessage (List, LB_GETCURSEL, 0, 0);
  312. MYASSERT (Index != LB_ERR);
  313. ItemData = (LONG) SendMessage (List, LB_GETITEMDATA, Index, 0);
  314. //
  315. // If ItemData is REGISTRY_DLL, then suppress the DLL.
  316. // Otherwise, delete loaded migration DLL
  317. //
  318. if (ItemData == REGISTRY_DLL) {
  319. Length = SendMessage (List, LB_GETTEXTLEN, Index, 0) + 1;
  320. Data = AllocText (Length);
  321. if (Data) {
  322. SendMessage (List, LB_GETTEXT, Index, (LPARAM) Data);
  323. MemDbSetValueEx (MEMDB_CATEGORY_DISABLED_MIGDLLS, NULL, NULL, Data, 0, NULL);
  324. FreeText (Data);
  325. }
  326. } else {
  327. RemoveDllFromList (ItemData);
  328. }
  329. //
  330. // Update the list box
  331. //
  332. TopIndex = SendMessage (List, LB_GETTOPINDEX, 0, 0);
  333. SendMessage (hdlg, WMX_UPDATE_LIST, 0, 0);
  334. SendMessage (List, LB_SETTOPINDEX, (WPARAM) TopIndex, 0);
  335. //
  336. // Disable remove button
  337. //
  338. SetFocus (GetDlgItem (hdlg, IDC_HAVE_DISK));
  339. EnableWindow (GetDlgItem (hdlg, IDC_REMOVE), FALSE);
  340. //
  341. // Redraw list box
  342. //
  343. SendMessage (List, WM_SETREDRAW, TRUE, 0);
  344. GetWindowRect (List, &ListRect);
  345. ScreenToClient (hdlg, (LPPOINT) &ListRect);
  346. ScreenToClient (hdlg, ((LPPOINT) &ListRect) + 1);
  347. InvalidateRect (hdlg, &ListRect, FALSE);
  348. break;
  349. case IDC_HAVE_DISK:
  350. ZeroMemory (&bi, sizeof (bi));
  351. bi.hwndOwner = hdlg;
  352. bi.pszDisplayName = SearchPathStr;
  353. bi.lpszTitle = GetStringResource (MSG_UPGRADE_MODULE_DLG_TITLE);
  354. bi.ulFlags = BIF_RETURNONLYFSDIRS;
  355. do {
  356. ItemIdList = SHBrowseForFolder (&bi);
  357. if (!ItemIdList) {
  358. break;
  359. }
  360. TurnOnWaitCursor();
  361. __try {
  362. if (!SHGetPathFromIDList (ItemIdList, SearchPathStr) ||
  363. *SearchPathStr == 0
  364. ) {
  365. //
  366. // Message box -- please reselect
  367. //
  368. OkBox (hdlg, MSG_BAD_SEARCH_PATH);
  369. continue;
  370. }
  371. rc = SearchForMigrationDlls (
  372. hdlg,
  373. SearchPathStr,
  374. &ActiveModulesFound,
  375. &OneModuleFound
  376. );
  377. //
  378. // If the search was successful, update the list, or
  379. // tell the user why the list is not changing.
  380. //
  381. // If the search was not successful, the search UI
  382. // already gave the error message, so we just continue
  383. // silently.
  384. //
  385. if (!OneModuleFound) {
  386. if (rc == ERROR_SUCCESS) {
  387. OkBox (hdlg, MSG_NO_MODULES_FOUND);
  388. }
  389. } else if (!ActiveModulesFound) {
  390. if (rc == ERROR_SUCCESS) {
  391. OkBox (hdlg, MSG_NO_NECESSARY_MODULES_FOUND);
  392. }
  393. } else {
  394. SendMessage (hdlg, WMX_UPDATE_LIST, 0, 0);
  395. }
  396. break;
  397. }
  398. __finally {
  399. TurnOffWaitCursor();
  400. }
  401. } while (TRUE);
  402. return TRUE;
  403. }
  404. }
  405. return FALSE;
  406. }
  407. BOOL
  408. CALLBACK
  409. SearchingDlgProc (
  410. HWND hdlg,
  411. UINT uMsg,
  412. WPARAM wParam,
  413. LPARAM lParam
  414. )
  415. {
  416. HWND Animation;
  417. DWORD ThreadId;
  418. static PSEARCHING_THREAD_DATA ThreadData;
  419. switch (uMsg) {
  420. case WM_INITDIALOG:
  421. //
  422. // Initialize thread data struct
  423. //
  424. ThreadData = (PSEARCHING_THREAD_DATA) lParam;
  425. ThreadData->hdlg = hdlg;
  426. if (!ThreadData->CancelEvent) {
  427. ThreadData->CancelEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
  428. MYASSERT (ThreadData->CancelEvent);
  429. }
  430. //
  431. // Load the avi resource for the animation.
  432. //
  433. Animation = GetDlgItem (hdlg, IDC_ANIMATE);
  434. Animate_Open (Animation, MAKEINTRESOURCE(IDA_FIND_COMP));
  435. PostMessage (hdlg, WMX_DIALOG_VISIBLE, 0, 0);
  436. return FALSE;
  437. case WMX_DIALOG_VISIBLE:
  438. ThreadData->ThreadHandle = CreateThread (
  439. NULL,
  440. 0,
  441. ThreadData->ThreadProc,
  442. (PVOID) ThreadData,
  443. 0,
  444. &ThreadId
  445. );
  446. if (!ThreadData->ThreadHandle) {
  447. LOG ((LOG_ERROR, "Failed to create thread for migration dll search."));
  448. EndDialog (hdlg, IDCANCEL);
  449. }
  450. return TRUE;
  451. case WMX_THREAD_DONE:
  452. EndDialog (hdlg, lParam);
  453. return TRUE;
  454. case WMX_WAIT_FOR_THREAD_TO_DIE:
  455. if (WAIT_OBJECT_0 == WaitForSingleObject (ThreadData->ThreadHandle, 50)) {
  456. TurnOffWaitCursor();
  457. EndDialog (hdlg, lParam);
  458. } else {
  459. PostMessage (hdlg, WMX_WAIT_FOR_THREAD_TO_DIE, wParam, lParam);
  460. }
  461. return TRUE;
  462. case WM_COMMAND:
  463. switch (LOWORD (wParam)) {
  464. case IDCANCEL:
  465. //
  466. // Set cancel event
  467. //
  468. SetEvent (ThreadData->CancelEvent);
  469. //
  470. // Stop the animation
  471. //
  472. UpdateWindow (hdlg);
  473. Animation = GetDlgItem (hdlg, IDC_ANIMATE);
  474. Animate_Stop (Animation);
  475. //
  476. // Loop until thread dies
  477. //
  478. PostMessage (hdlg, WMX_WAIT_FOR_THREAD_TO_DIE, 0, ERROR_CANCELLED);
  479. TurnOnWaitCursor();
  480. return TRUE;
  481. }
  482. break;
  483. case WM_DESTROY:
  484. if (ThreadData->CancelEvent) {
  485. CloseHandle (ThreadData->CancelEvent);
  486. ThreadData->CancelEvent = NULL;
  487. }
  488. if (ThreadData->ThreadHandle) {
  489. CloseHandle (ThreadData->ThreadHandle);
  490. ThreadData->ThreadHandle = NULL;
  491. }
  492. break;
  493. }
  494. return FALSE;
  495. }
  496. DWORD
  497. WINAPI
  498. pSearchForMigrationDlls (
  499. PVOID Param
  500. )
  501. {
  502. PSEARCHING_THREAD_DATA Data;
  503. HWND OldParent;
  504. LONG rc;
  505. Data = (PSEARCHING_THREAD_DATA) Param;
  506. OldParent = g_ParentWnd;
  507. g_ParentWnd = Data->hdlg;
  508. LogReInit (&g_ParentWnd, NULL);
  509. __try {
  510. //
  511. // Open event handle, closed by thread owner
  512. //
  513. Data->CancelEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
  514. if (!Data->CancelEvent) {
  515. DEBUGMSG ((DBG_ERROR, "pSearchForMigrationDlls: Could not create cancel event"));
  516. __leave;
  517. }
  518. Data->ActiveMatches = ScanPathForMigrationDlls (
  519. Data->SearchStr,
  520. Data->CancelEvent,
  521. &Data->MatchFound
  522. );
  523. if (WaitForSingleObject (Data->CancelEvent, 0) != WAIT_OBJECT_0) {
  524. rc = GetLastError();
  525. PostMessage (Data->hdlg, WMX_THREAD_DONE, 0, rc);
  526. }
  527. }
  528. __finally {
  529. LogReInit (&OldParent, NULL);
  530. }
  531. return 0;
  532. }
  533. LONG
  534. SearchForMigrationDlls (
  535. IN HWND Parent,
  536. IN PCTSTR SearchPathStr,
  537. OUT UINT *ActiveModulesFound,
  538. OUT PBOOL OneValidDllFound
  539. )
  540. {
  541. SEARCHING_THREAD_DATA Data;
  542. LONG rc;
  543. if (!SearchPathStr || *SearchPathStr == 0) {
  544. return IDNO;
  545. }
  546. ZeroMemory (&Data, sizeof (Data));
  547. Data.SearchStr = SearchPathStr;
  548. Data.ThreadProc = pSearchForMigrationDlls;
  549. rc = DialogBoxParam (
  550. g_hInst,
  551. MAKEINTRESOURCE(IDD_SEARCHING_DLG),
  552. Parent,
  553. SearchingDlgProc,
  554. (LPARAM) &Data
  555. );
  556. *ActiveModulesFound = Data.ActiveMatches;
  557. *OneValidDllFound = Data.MatchFound;
  558. return rc;
  559. }
  560. LONG
  561. SearchForDrivers (
  562. IN HWND Parent,
  563. IN PCTSTR SearchPathStr,
  564. OUT BOOL *DriversFound
  565. )
  566. {
  567. SEARCHING_THREAD_DATA Data;
  568. LONG rc;
  569. if (!SearchPathStr || *SearchPathStr == 0) {
  570. return IDNO;
  571. }
  572. ZeroMemory (&Data, sizeof (Data));
  573. Data.SearchStr = SearchPathStr;
  574. Data.ThreadProc = pSearchForDrivers;
  575. rc = DialogBoxParam (
  576. g_hInst,
  577. MAKEINTRESOURCE(IDD_SEARCHING_DLG),
  578. Parent,
  579. SearchingDlgProc,
  580. (LPARAM) &Data
  581. );
  582. *DriversFound = Data.MatchFound;
  583. return rc;
  584. }
  585. DWORD
  586. WINAPI
  587. pSearchForDomainThread (
  588. PVOID Param
  589. )
  590. {
  591. PSEARCHING_THREAD_DATA Data;
  592. LONG rc;
  593. NETRESOURCE_ENUM e;
  594. Data = (PSEARCHING_THREAD_DATA) Param;
  595. Data->ActiveMatches = 0;
  596. __try {
  597. //
  598. // Search all workgroups and domains for a computer account.
  599. //
  600. if (EnumFirstNetResource (&e, 0, 0, 0)) {
  601. do {
  602. if (WaitForSingleObject (Data->CancelEvent, 0) == WAIT_OBJECT_0) {
  603. AbortNetResourceEnum (&e);
  604. SetLastError (ERROR_CANCELLED);
  605. __leave;
  606. }
  607. if (e.Domain) {
  608. if (1 == DoesComputerAccountExistOnDomain (e.RemoteName, Data->SearchStr, FALSE)) {
  609. //
  610. // Return first match
  611. //
  612. DEBUGMSG ((DBG_NAUSEA, "Account found for %s on %s", Data->SearchStr, e.RemoteName));
  613. StringCopy (Data->MatchStr, e.RemoteName);
  614. Data->ActiveMatches = 1;
  615. AbortNetResourceEnum (&e);
  616. SetLastError (ERROR_SUCCESS);
  617. __leave;
  618. }
  619. DEBUGMSG ((DBG_NAUSEA, "%s does not have an account for %s", e.RemoteName, Data->SearchStr));
  620. }
  621. } while (EnumNextNetResource (&e));
  622. }
  623. }
  624. __finally {
  625. Data->MatchFound = (Data->ActiveMatches != 0);
  626. if (WaitForSingleObject (Data->CancelEvent, 0) != WAIT_OBJECT_0) {
  627. rc = GetLastError();
  628. PostMessage (Data->hdlg, WMX_THREAD_DONE, 0, rc);
  629. }
  630. }
  631. return 0;
  632. }
  633. LONG
  634. SearchForDomain (
  635. IN HWND Parent,
  636. IN PCTSTR ComputerName,
  637. OUT BOOL *AccountFound,
  638. OUT PTSTR DomainName
  639. )
  640. {
  641. SEARCHING_THREAD_DATA Data;
  642. LONG rc;
  643. ZeroMemory (&Data, sizeof (Data));
  644. Data.SearchStr = ComputerName;
  645. Data.ThreadProc = pSearchForDomainThread;
  646. Data.MatchStr = DomainName;
  647. rc = DialogBoxParam (
  648. g_hInst,
  649. MAKEINTRESOURCE(IDD_SEARCHING_DLG),
  650. Parent,
  651. SearchingDlgProc,
  652. (LPARAM) &Data
  653. );
  654. *AccountFound = Data.MatchFound;
  655. return rc;
  656. }
  657. BOOL
  658. ChangeNameDlg (
  659. IN HWND Parent,
  660. IN PCTSTR NameGroup,
  661. IN PCTSTR OrgName,
  662. IN OUT PTSTR NewName
  663. )
  664. /*++
  665. Routine Description:
  666. ChangeNameDlg creates a dialog to allow the user to alter Setup-
  667. generated replacement names.
  668. Arguments:
  669. Parent - Specifies handle to the parent window for the dialog
  670. NameGroup - Specifies the name group being processed, used to
  671. verify the new name does not collide with an existing
  672. name in the name group.
  673. OrgName - Specifies the original name as it was found on the Win9x
  674. machine
  675. NewName - Specifies the Setup-recommended new name, or the last change
  676. made by the user. Receives the user's change.
  677. Return Value:
  678. TRUE if the name was changed, or FALSE if no change was made.
  679. --*/
  680. {
  681. TCHAR NewNameBackup[MEMDB_MAX];
  682. CHANGE_NAME_PARAMS Data;
  683. StringCopy (NewNameBackup, NewName);
  684. Data.NameGroup = NameGroup;
  685. Data.OrgName = OrgName;
  686. Data.LastNewName = NewNameBackup;
  687. Data.NewNameBuf = NewName;
  688. DialogBoxParam (
  689. g_hInst,
  690. MAKEINTRESOURCE (IDD_NAME_CHANGE_DLG),
  691. Parent,
  692. pChangeNameDlgProc,
  693. (LPARAM) &Data
  694. );
  695. return !StringMatch (NewNameBackup, NewName);
  696. }
  697. BOOL
  698. CALLBACK
  699. pChangeNameDlgProc (
  700. IN HWND hdlg,
  701. IN UINT uMsg,
  702. IN WPARAM wParam,
  703. IN LPARAM lParam
  704. )
  705. /*++
  706. Routine Description:
  707. pChangeNameDlgProc implements the dialog procedure for the change
  708. name dialog. There are two cases handled by this code:
  709. 1. The WM_INITDIALOG message handler initializes the edit
  710. control with the text from the last change to the name.
  711. 2. The IDOK command handler verifies that the supplied name
  712. does not collide with an existing name in the group.
  713. Arguments:
  714. hdlg - Specifies the dialog handle
  715. uMsg - Specifies the message to process
  716. wParam - Specifies message-specific data
  717. lParam - Specifies message-specific data
  718. Return Value:
  719. TRUE if the message was handled by this procedure, or FALSE
  720. if the system should handle the message.
  721. --*/
  722. {
  723. static PCHANGE_NAME_PARAMS Data;
  724. TCHAR NewName[MEMDB_MAX];
  725. switch (uMsg) {
  726. case WM_INITDIALOG:
  727. //
  728. // Initialize data struct
  729. //
  730. Data = (PCHANGE_NAME_PARAMS) lParam;
  731. //
  732. // Fill the dialog box controls
  733. //
  734. SetDlgItemText (hdlg, IDC_ORIGINAL_NAME, Data->OrgName);
  735. SetDlgItemText (hdlg, IDC_NEW_NAME, Data->LastNewName);
  736. return FALSE; // let system set the focus
  737. case WM_COMMAND:
  738. switch (LOWORD (wParam)) {
  739. case IDOK:
  740. //
  741. // Obtain the new name, and make sure it is legal.
  742. //
  743. GetDlgItemText (
  744. hdlg,
  745. IDC_NEW_NAME,
  746. NewName,
  747. sizeof (NewName) / sizeof (NewName[0])
  748. );
  749. //
  750. // If user changed the name, verify name is not in the name group
  751. //
  752. if (!StringIMatch (NewName, Data->LastNewName)) {
  753. if (!ValidateName (hdlg, Data->NameGroup, NewName)) {
  754. return TRUE;
  755. }
  756. }
  757. //
  758. // Copy name to buffer and close dialog
  759. //
  760. StringCopy (Data->NewNameBuf, NewName);
  761. EndDialog (hdlg, IDOK);
  762. return TRUE;
  763. case IDCANCEL:
  764. EndDialog (hdlg, IDCANCEL);
  765. return TRUE;
  766. }
  767. break;
  768. }
  769. return FALSE;
  770. }
  771. BOOL
  772. CredentialsDlg (
  773. IN HWND Parent,
  774. IN OUT PCREDENTIALS Credentials
  775. )
  776. /*++
  777. Routine Description:
  778. CredentialsDlg creates a dialog to allow the user to enter computer
  779. domain credentials, which are used in GUI mode to join the computer
  780. to a domain.
  781. Arguments:
  782. Parent - Specifies handle to the parent window for the dialog
  783. Credentials - Specifies the credentials to use, receives the user's
  784. changes
  785. Return Value:
  786. TRUE if a name was changed, or FALSE if no change was made.
  787. --*/
  788. {
  789. Credentials->Change = TRUE;
  790. DialogBoxParam (
  791. g_hInst,
  792. MAKEINTRESOURCE (IDD_DOMAIN_CREDENTIALS_DLG),
  793. Parent,
  794. pCredentialsDlgProc,
  795. (LPARAM) Credentials
  796. );
  797. return Credentials->Change;
  798. }
  799. VOID
  800. pRemoveWhitespace (
  801. IN OUT PTSTR String
  802. )
  803. {
  804. PCTSTR Start;
  805. PCTSTR End;
  806. Start = SkipSpace (String);
  807. if (Start != String) {
  808. End = GetEndOfString (Start) + 1;
  809. MoveMemory (String, Start, (PBYTE) End - (PBYTE) Start);
  810. }
  811. TruncateTrailingSpace (String);
  812. }
  813. BOOL
  814. CALLBACK
  815. pCredentialsDlgProc (
  816. IN HWND hdlg,
  817. IN UINT uMsg,
  818. IN WPARAM wParam,
  819. IN LPARAM lParam
  820. )
  821. /*++
  822. Routine Description:
  823. pCredentialsDlgProc implements the dialog procedure for the
  824. administrator credentials dialog. There are two cases handled
  825. by this code:
  826. 1. The WM_INITDIALOG message handler initializes the edit
  827. control with the text from the last change.
  828. 2. The IDOK command handler gets the domain credentials and
  829. returns them to the caller.
  830. Arguments:
  831. hdlg - Specifies the dialog handle
  832. uMsg - Specifies the message to process
  833. wParam - Specifies message-specific data
  834. lParam - Specifies message-specific data
  835. Return Value:
  836. TRUE if the message was handled by this procedure, or FALSE
  837. if the system should handle the message.
  838. --*/
  839. {
  840. static PCREDENTIALS Credentials;
  841. CREDENTIALS Temp;
  842. //LONG rc;
  843. //TCHAR ComputerName[MAX_COMPUTER_NAME + 1];
  844. TCHAR UserName[USER_NAME_SIZE];
  845. TCHAR CurrentUserName[MAX_USER_NAME];
  846. TCHAR Domain[USER_NAME_SIZE];
  847. DWORD Size;
  848. PTSTR p;
  849. switch (uMsg) {
  850. case WM_INITDIALOG:
  851. //
  852. // Initialize data struct
  853. //
  854. Credentials = (PCREDENTIALS) lParam;
  855. //
  856. // Fill the dialog box controls
  857. //
  858. //SendMessage (GetDlgItem (hdlg, IDC_DOMAIN), EM_LIMITTEXT, MAX_COMPUTER_NAME, 0);
  859. SendMessage (GetDlgItem (hdlg, IDC_USER_NAME), EM_LIMITTEXT, USER_NAME_SIZE, 0);
  860. SendMessage (GetDlgItem (hdlg, IDC_PASSWORD), EM_LIMITTEXT, MAX_PASSWORD, 0);
  861. //SetDlgItemText (hdlg, IDC_DOMAIN, Credentials->DomainName);
  862. SetDlgItemText (hdlg, IDC_USER_NAME, Credentials->AdminName);
  863. SetDlgItemText (hdlg, IDC_PASSWORD, Credentials->Password);
  864. Credentials->Change = FALSE;
  865. return FALSE; // let system set the focus
  866. case WM_COMMAND:
  867. switch (LOWORD (wParam)) {
  868. case IDOK:
  869. //
  870. // Obtain the new text
  871. //
  872. CopyMemory (&Temp, Credentials, sizeof (CREDENTIALS));
  873. /*
  874. GetDlgItemText (
  875. hdlg,
  876. IDC_DOMAIN,
  877. Temp.DomainName,
  878. sizeof (Temp.DomainName) / sizeof (Temp.DomainName[0])
  879. );
  880. */
  881. GetDlgItemText (
  882. hdlg,
  883. IDC_USER_NAME,
  884. Domain,
  885. ARRAYSIZE(Domain)
  886. );
  887. GetDlgItemText (
  888. hdlg,
  889. IDC_PASSWORD,
  890. Temp.Password,
  891. ARRAYSIZE(Temp.Password)
  892. );
  893. p = _tcschr (Domain, TEXT('\\'));
  894. if (p) {
  895. *p = 0;
  896. StringCopy (UserName, p + 1);
  897. } else {
  898. StringCopy (UserName, Domain);
  899. *Domain = 0;
  900. }
  901. pRemoveWhitespace (Domain);
  902. pRemoveWhitespace (UserName);
  903. if (!*UserName && !*Temp.Password) {
  904. EndDialog (hdlg, IDCANCEL);
  905. return TRUE;
  906. }
  907. if (*Domain) {
  908. if (!ValidateDomainNameChars (Domain)) {
  909. OkBox (hdlg, MSG_USER_IS_BOGUS);
  910. return TRUE;
  911. }
  912. }
  913. if (!ValidateUserNameChars (UserName)) {
  914. OkBox (hdlg, MSG_USER_IS_BOGUS);
  915. return TRUE;
  916. }
  917. if (*Domain) {
  918. wsprintf (Temp.AdminName, TEXT("%s\\%s"), Domain, UserName);
  919. } else {
  920. StringCopy (Temp.AdminName, UserName);
  921. }
  922. Size = sizeof (CurrentUserName);
  923. GetUserName (CurrentUserName, &Size);
  924. if (StringIMatch (CurrentUserName, UserName)) {
  925. if (IDNO == YesNoBox (hdlg, MSG_USER_IS_CURRENT_USER)) {
  926. OkBox (hdlg, MSG_CONTACT_NET_ADMIN);
  927. return TRUE;
  928. }
  929. }
  930. /*
  931. if (!ValidateName (hdlg, TEXT("ComputerDomain"), Temp.DomainName)) {
  932. OkBox (hdlg, MSG_SPECIFIED_DOMAIN_RESPONSE_POPUP);
  933. return TRUE;
  934. }
  935. GetUpgradeComputerName (ComputerName);
  936. rc = DoesComputerAccountExistOnDomain (Temp.DomainName, ComputerName, TRUE);
  937. if (rc == -1) {
  938. OkBox (hdlg, MSG_SPECIFIED_DOMAIN_RESPONSE_POPUP);
  939. return TRUE;
  940. }
  941. */
  942. CopyMemory (Credentials, &Temp, sizeof (CREDENTIALS));
  943. Credentials->Change = TRUE;
  944. EndDialog (hdlg, IDOK);
  945. return TRUE;
  946. case IDCANCEL:
  947. EndDialog (hdlg, IDCANCEL);
  948. return TRUE;
  949. }
  950. break;
  951. }
  952. return FALSE;
  953. }
  954. BOOL
  955. CALLBACK
  956. UntrustedDllProc (
  957. HWND hdlg,
  958. UINT uMsg,
  959. WPARAM wParam,
  960. LPARAM lParam
  961. )
  962. {
  963. UINT Control;
  964. switch (uMsg) {
  965. case WM_INITDIALOG:
  966. CheckDlgButton (hdlg, IDC_DONT_TRUST_IT, BST_CHECKED);
  967. return FALSE;
  968. case WM_COMMAND:
  969. switch (LOWORD (wParam)) {
  970. case IDOK:
  971. Control = IDC_DONT_TRUST_IT;
  972. if (IsDlgButtonChecked (hdlg, Control) == BST_UNCHECKED) {
  973. Control = IDC_TRUST_IT;
  974. if (IsDlgButtonChecked (hdlg, Control) == BST_UNCHECKED) {
  975. Control = IDC_TRUST_ANY;
  976. }
  977. }
  978. EndDialog (hdlg, Control);
  979. break;
  980. case IDCANCEL:
  981. EndDialog (hdlg, IDCANCEL);
  982. return TRUE;
  983. }
  984. break;
  985. }
  986. return FALSE;
  987. }
  988. UINT
  989. UI_UntrustedDll (
  990. IN PCTSTR DllPath
  991. )
  992. /*++
  993. Routine Description:
  994. UI_UntrustedDll asks the user if they give permission to trust an upgrade
  995. module that does not have a digital signature, or is not trusted by the
  996. system.
  997. Arguments:
  998. DllPath - Specifies path to DLL that is not trusted
  999. Return Value:
  1000. The control ID of the option selected by the user.
  1001. --*/
  1002. {
  1003. return IDC_TRUST_ANY; // temporary -- trust them all
  1004. /*
  1005. if (g_ParentWnd == NULL) {
  1006. return IDC_TRUST_ANY; // temporary -- trust them all
  1007. }
  1008. return DialogBox (g_hInst, MAKEINTRESOURCE(IDD_TRUST_FAIL_DLG), g_ParentWnd, UntrustedDllProc);
  1009. */
  1010. }
  1011. #ifdef PRERELEASE
  1012. BOOL
  1013. CALLBACK
  1014. AutoStressDlgProc (
  1015. HWND hdlg,
  1016. UINT uMsg,
  1017. WPARAM wParam,
  1018. LPARAM lParam
  1019. )
  1020. {
  1021. TCHAR Data[1024];
  1022. DWORD Flags;
  1023. HKEY Key;
  1024. PCTSTR User;
  1025. DWORD Size;
  1026. switch (uMsg) {
  1027. case WM_INITDIALOG:
  1028. Key = OpenRegKeyStr (S_MSNP32);
  1029. if (Key) {
  1030. Data[0] = 0;
  1031. User = GetRegValueData (Key, S_AUTHENTICATING_AGENT);
  1032. if (User) {
  1033. StringCopy (Data, User);
  1034. MemFree (g_hHeap, 0, User);
  1035. Size = MAX_USER_NAME;
  1036. GetUserName (AppendWack (Data), &Size);
  1037. SetDlgItemText (hdlg, IDC_USERNAME, Data);
  1038. }
  1039. CloseRegKey (Key);
  1040. }
  1041. return FALSE;
  1042. case WM_COMMAND:
  1043. switch (LOWORD (wParam)) {
  1044. case IDOK:
  1045. GetDlgItemText (hdlg, IDC_USERNAME, Data, 1024);
  1046. MemDbSetValueEx (MEMDB_CATEGORY_STATE, S_AUTOSTRESS_USER, Data, NULL, 0, NULL);
  1047. GetDlgItemText (hdlg, IDC_PASSWORD, Data, 1024);
  1048. MemDbSetValueEx (MEMDB_CATEGORY_STATE, S_AUTOSTRESS_PASSWORD, Data, NULL, 0, NULL);
  1049. GetDlgItemText (hdlg, IDC_OFFICE, Data, 1024);
  1050. MemDbSetValueEx (MEMDB_CATEGORY_STATE, S_AUTOSTRESS_OFFICE, Data, NULL, 0, NULL);
  1051. GetDlgItemText (hdlg, IDC_DBGMACHINE, Data, 1024);
  1052. MemDbSetValueEx (MEMDB_CATEGORY_STATE, S_AUTOSTRESS_DBG, Data, NULL, 0, NULL);
  1053. Flags = 0;
  1054. if (IsDlgButtonChecked (hdlg, IDC_PRIVATE) == BST_CHECKED) {
  1055. Flags |= AUTOSTRESS_PRIVATE;
  1056. }
  1057. if (IsDlgButtonChecked (hdlg, IDC_MANUAL_TESTS) == BST_CHECKED) {
  1058. Flags |= AUTOSTRESS_MANUAL_TESTS;
  1059. }
  1060. wsprintf (Data, TEXT("%u"), Flags);
  1061. MemDbSetValueEx (MEMDB_CATEGORY_STATE, S_AUTOSTRESS_FLAGS, Data, NULL, 0, NULL);
  1062. EndDialog (hdlg, IDOK);
  1063. break;
  1064. }
  1065. break;
  1066. }
  1067. return FALSE;
  1068. }
  1069. DWORD
  1070. DoAutoStressDlg (
  1071. PVOID Unused
  1072. )
  1073. {
  1074. DialogBox (g_hInst, MAKEINTRESOURCE(IDD_STRESS), g_ParentWndAlwaysValid, AutoStressDlgProc);
  1075. return 0;
  1076. }
  1077. #endif