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.

1147 lines
32 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: analyze.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "hdwwiz.h"
  11. #include <infstr.h>
  12. BOOL
  13. DeviceHasForcedConfig(
  14. DEVINST DeviceInst
  15. )
  16. /*++
  17. This function checks to see if a given DevInst has a forced config or
  18. not.
  19. --*/
  20. {
  21. CONFIGRET ConfigRet;
  22. ConfigRet = CM_Get_First_Log_Conf_Ex(NULL, DeviceInst, FORCED_LOG_CONF, NULL);
  23. if (ConfigRet == CR_SUCCESS)
  24. {
  25. return TRUE;
  26. }
  27. return FALSE;
  28. }
  29. INT_PTR CALLBACK
  30. InstallNewDeviceDlgProc(
  31. HWND hDlg,
  32. UINT wMsg,
  33. WPARAM wParam,
  34. LPARAM lParam
  35. )
  36. {
  37. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  38. switch (wMsg) {
  39. case WM_INITDIALOG: {
  40. HICON hIcon;
  41. HWND hwndParentDlg;
  42. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  43. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  44. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  45. hIcon = LoadIcon(hHdwWiz,MAKEINTRESOURCE(IDI_HDWWIZICON));
  46. if (hIcon) {
  47. hwndParentDlg = GetParent(hDlg);
  48. SendMessage(hwndParentDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
  49. SendMessage(hwndParentDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
  50. }
  51. break;
  52. }
  53. case WM_COMMAND:
  54. break;
  55. case WM_NOTIFY:
  56. switch (((NMHDR FAR *)lParam)->code) {
  57. case PSN_SETACTIVE: {
  58. int PrevPage;
  59. PrevPage = HardwareWiz->PrevPage;
  60. HardwareWiz->PrevPage = IDD_INSTALLNEWDEVICE;
  61. //
  62. // If we are coming back then this is effectively a Cancel
  63. // of the install.
  64. //
  65. if (PrevPage == IDD_ADDDEVICE_SELECTDEVICE ||
  66. PrevPage == IDD_ADDDEVICE_SELECTCLASS )
  67. {
  68. PropSheet_PressButton(GetParent(hDlg), PSBTN_CANCEL);
  69. break;
  70. }
  71. //
  72. // If we have a class then jump into SelectDevice.
  73. // otherwise goto search pages.
  74. //
  75. if (HardwareWiz->ClassGuidSelected) {
  76. HardwareWiz->EnterInto = IDD_ADDDEVICE_SELECTDEVICE;
  77. HardwareWiz->EnterFrom = IDD_INSTALLNEWDEVICE;
  78. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_SELECTDEVICE);
  79. } else {
  80. HardwareWiz->EnterInto = IDD_ADDDEVICE_SELECTCLASS;
  81. HardwareWiz->EnterFrom = IDD_INSTALLNEWDEVICE;
  82. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_SELECTCLASS);
  83. }
  84. }
  85. break;
  86. case PSN_WIZNEXT:
  87. break;
  88. case PSN_RESET:
  89. HardwareWiz->Cancelled = TRUE;
  90. break;
  91. }
  92. break;
  93. default:
  94. return(FALSE);
  95. }
  96. return(TRUE);
  97. }
  98. BOOL
  99. CompareInfIdToHardwareIds(
  100. LPTSTR HardwareId,
  101. LPTSTR InfDeviceId
  102. )
  103. /*++
  104. This function takes a pointer to the Hardware/Compatible Id list for a device and
  105. a DeviceId that we got from the INF. It enumerates through all of the device's
  106. Hardware and Compatible Ids comparing them against the Device Id we got from the INF.
  107. If one of the device's Hardware or Compatible Ids match the API returns TRUE, otherwise
  108. it returns FALSE.
  109. --*/
  110. {
  111. while (*HardwareId) {
  112. if (_wcsicmp(HardwareId, InfDeviceId) == 0) {
  113. return TRUE;
  114. }
  115. HardwareId = HardwareId + lstrlen(HardwareId) + 1;
  116. }
  117. return(FALSE);
  118. }
  119. /*
  120. * RegisterDeviceNode
  121. *
  122. * Determines if device is a legacy or pnp style device,
  123. * Registers the device (phantomn devnode to real devnode).
  124. *
  125. */
  126. DWORD
  127. RegisterDeviceNode(
  128. HWND hDlg,
  129. PHARDWAREWIZ HardwareWiz
  130. )
  131. {
  132. DWORD FieldCount, Index, Len;
  133. DWORD AnalyzeResult;
  134. HINF hInf = INVALID_HANDLE_VALUE;
  135. LPTSTR HardwareId;
  136. SP_DRVINFO_DATA DriverInfoData;
  137. PSP_DRVINFO_DETAIL_DATA DriverInfoDetailData = NULL;
  138. INFCONTEXT InfContext;
  139. TCHAR InfDeviceID[MAX_DEVICE_ID_LEN];
  140. TCHAR SectionName[LINE_LEN*2];
  141. LONG LastError;
  142. HardwareWiz->PnpDevice= FALSE;
  143. //
  144. // Fetch the DriverInfoDetail, with enough space for lots of hardwareIDs.
  145. //
  146. Len = sizeof(SP_DRVINFO_DETAIL_DATA) + MAX_PATH*sizeof(TCHAR);
  147. DriverInfoDetailData = LocalAlloc(LPTR, Len);
  148. if (!DriverInfoDetailData) {
  149. goto AnalyzeExit;
  150. }
  151. DriverInfoDetailData->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);
  152. DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
  153. if (!SetupDiGetSelectedDriver(HardwareWiz->hDeviceInfo,
  154. &HardwareWiz->DeviceInfoData,
  155. &DriverInfoData
  156. ))
  157. {
  158. goto AnalyzeExit;
  159. }
  160. if (!SetupDiGetDriverInfoDetail(HardwareWiz->hDeviceInfo,
  161. &HardwareWiz->DeviceInfoData,
  162. &DriverInfoData,
  163. DriverInfoDetailData,
  164. Len,
  165. &Len
  166. ))
  167. {
  168. if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
  169. LocalFree(DriverInfoDetailData);
  170. DriverInfoDetailData = LocalAlloc(LPTR, Len);
  171. if (!DriverInfoDetailData) {
  172. goto AnalyzeExit;
  173. }
  174. DriverInfoDetailData->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);
  175. if (!SetupDiGetDriverInfoDetail(HardwareWiz->hDeviceInfo,
  176. &HardwareWiz->DeviceInfoData,
  177. &DriverInfoData,
  178. DriverInfoDetailData,
  179. Len,
  180. NULL
  181. ))
  182. {
  183. goto AnalyzeExit;
  184. }
  185. } else {
  186. goto AnalyzeExit;
  187. }
  188. }
  189. //
  190. // Get a handle to the inf file.
  191. //
  192. hInf = SetupOpenInfFile(DriverInfoDetailData->InfFileName,
  193. NULL,
  194. INF_STYLE_WIN4,
  195. NULL
  196. );
  197. if (hInf == INVALID_HANDLE_VALUE) {
  198. //
  199. // If this is an old style inf file, then we can't write out
  200. // the logconfigs for classes which allow old style infs this is Ok,
  201. // If its an invalid or missing inf, it will fail further
  202. // down the chain of execution
  203. //
  204. goto AnalyzeExit;
  205. }
  206. //
  207. // Check InfFile for ControlFlags section for INFSTR_KEY_COPYFILESONLY
  208. //
  209. if (SetupFindFirstLine(hInf,
  210. INFSTR_CONTROLFLAGS_SECTION,
  211. INFSTR_KEY_COPYFILESONLY,
  212. &InfContext
  213. ))
  214. {
  215. HardwareId = DriverInfoDetailData->HardwareID;
  216. do {
  217. FieldCount = SetupGetFieldCount(&InfContext);
  218. Index = 0;
  219. while (Index++ < FieldCount) {
  220. if (SetupGetStringField(&InfContext,
  221. Index,
  222. InfDeviceID,
  223. sizeof(InfDeviceID)/sizeof(TCHAR),
  224. NULL
  225. ))
  226. {
  227. if (CompareInfIdToHardwareIds(HardwareId, InfDeviceID)) {
  228. HardwareWiz->PnpDevice= TRUE;
  229. goto AnalyzeExit;
  230. }
  231. }
  232. }
  233. } while (SetupFindNextMatchLine(&InfContext,
  234. INFSTR_KEY_COPYFILESONLY,
  235. &InfContext)
  236. );
  237. }
  238. //
  239. // If there are factdef logconfigs install them as a forced config.
  240. // These are the factory default jumper settings for the hw.
  241. //
  242. if (SetupDiGetActualSectionToInstall(hInf,
  243. DriverInfoDetailData->SectionName,
  244. SectionName,
  245. SIZECHARS(SectionName),
  246. NULL,
  247. NULL
  248. ))
  249. {
  250. lstrcat(SectionName, TEXT(".") INFSTR_SUBKEY_FACTDEF);
  251. if (SetupFindFirstLine(hInf, SectionName, NULL, &InfContext)) {
  252. SetupInstallFromInfSection(hDlg,
  253. hInf,
  254. SectionName,
  255. SPINST_LOGCONFIG | SPINST_SINGLESECTION | SPINST_LOGCONFIG_IS_FORCED,
  256. NULL,
  257. NULL,
  258. 0,
  259. NULL,
  260. NULL,
  261. HardwareWiz->hDeviceInfo,
  262. &HardwareWiz->DeviceInfoData
  263. );
  264. }
  265. }
  266. AnalyzeExit:
  267. if (DriverInfoDetailData) {
  268. LocalFree(DriverInfoDetailData);
  269. }
  270. if (hInf != INVALID_HANDLE_VALUE) {
  271. SetupCloseInfFile(hInf);
  272. }
  273. //
  274. // Register the phantom device in preparation for install.
  275. // Once this is registered we MUST remove it from the registry
  276. // if the device install is not completed.
  277. //
  278. if (SetupDiCallClassInstaller(DIF_REGISTERDEVICE,
  279. HardwareWiz->hDeviceInfo,
  280. &HardwareWiz->DeviceInfoData
  281. ))
  282. {
  283. LastError = ERROR_SUCCESS;
  284. } else {
  285. LastError = GetLastError();
  286. }
  287. HardwareWiz->Registered = LastError == ERROR_SUCCESS;
  288. return LastError;
  289. }
  290. DWORD
  291. ProcessLogConfig(
  292. HWND hDlg,
  293. PHARDWAREWIZ HardwareWiz
  294. )
  295. {
  296. DWORD FieldCount, Index, Len;
  297. DWORD AnalyzeResult;
  298. HINF hInf = INVALID_HANDLE_VALUE;
  299. LPTSTR HardwareId;
  300. SP_DRVINFO_DATA DriverInfoData;
  301. PSP_DRVINFO_DETAIL_DATA DriverInfoDetailData = NULL;
  302. INFCONTEXT InfContext;
  303. TCHAR InfDeviceID[MAX_DEVICE_ID_LEN];
  304. TCHAR SectionName[LINE_LEN*2];
  305. LONG LastError = ERROR_SUCCESS;
  306. //
  307. // Fetch the DriverInfoDetail, with enough space for lots of hardwareIDs.
  308. //
  309. Len = sizeof(SP_DRVINFO_DETAIL_DATA) + MAX_PATH*sizeof(TCHAR);
  310. DriverInfoDetailData = LocalAlloc(LPTR, Len);
  311. if (!DriverInfoDetailData) {
  312. goto AnalyzeExit;
  313. }
  314. DriverInfoDetailData->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);
  315. DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
  316. if (!SetupDiGetSelectedDriver(HardwareWiz->hDeviceInfo,
  317. &HardwareWiz->DeviceInfoData,
  318. &DriverInfoData
  319. ))
  320. {
  321. goto AnalyzeExit;
  322. }
  323. if (!SetupDiGetDriverInfoDetail(HardwareWiz->hDeviceInfo,
  324. &HardwareWiz->DeviceInfoData,
  325. &DriverInfoData,
  326. DriverInfoDetailData,
  327. Len,
  328. &Len
  329. ))
  330. {
  331. if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
  332. LocalFree(DriverInfoDetailData);
  333. DriverInfoDetailData = LocalAlloc(LPTR, Len);
  334. if (!DriverInfoDetailData) {
  335. goto AnalyzeExit;
  336. }
  337. DriverInfoDetailData->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);
  338. if (!SetupDiGetDriverInfoDetail(HardwareWiz->hDeviceInfo,
  339. &HardwareWiz->DeviceInfoData,
  340. &DriverInfoData,
  341. DriverInfoDetailData,
  342. Len,
  343. NULL
  344. ))
  345. {
  346. goto AnalyzeExit;
  347. }
  348. } else {
  349. goto AnalyzeExit;
  350. }
  351. }
  352. //
  353. // Get a handle to the inf file.
  354. //
  355. hInf = SetupOpenInfFile(DriverInfoDetailData->InfFileName,
  356. NULL,
  357. INF_STYLE_WIN4,
  358. NULL
  359. );
  360. if (hInf == INVALID_HANDLE_VALUE) {
  361. //
  362. // If this is an old style inf file, then we can't write out
  363. // the logconfigs for classes which allow old style infs this is Ok,
  364. // If its an invalid or missing inf, it will fail further
  365. // down the chain of execution
  366. //
  367. goto AnalyzeExit;
  368. }
  369. //
  370. // Install any LogConfig entries in the install section.
  371. //
  372. if (SetupDiGetActualSectionToInstall(hInf,
  373. DriverInfoDetailData->SectionName,
  374. SectionName,
  375. SIZECHARS(SectionName),
  376. NULL,
  377. NULL
  378. ))
  379. {
  380. SetupInstallFromInfSection(hDlg,
  381. hInf,
  382. SectionName,
  383. SPINST_LOGCONFIG,
  384. NULL,
  385. NULL,
  386. 0,
  387. NULL,
  388. NULL,
  389. HardwareWiz->hDeviceInfo,
  390. &HardwareWiz->DeviceInfoData
  391. );
  392. }
  393. AnalyzeExit:
  394. if (DriverInfoDetailData) {
  395. LocalFree(DriverInfoDetailData);
  396. }
  397. if (hInf != INVALID_HANDLE_VALUE) {
  398. SetupCloseInfFile(hInf);
  399. }
  400. return LastError;
  401. }
  402. INT_PTR CALLBACK
  403. HdwAnalyzeDlgProc(
  404. HWND hDlg,
  405. UINT wMsg,
  406. WPARAM wParam,
  407. LPARAM lParam
  408. )
  409. {
  410. HICON hicon;
  411. HWND hwndParentDlg = GetParent(hDlg);
  412. PHARDWAREWIZ HardwareWiz;
  413. PSP_INSTALLWIZARD_DATA InstallWizard;
  414. if (wMsg == WM_INITDIALOG) {
  415. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  416. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  417. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  418. HardwareWiz->AnalyzeResult = 0;
  419. return TRUE;
  420. }
  421. HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  422. InstallWizard = &HardwareWiz->InstallDynaWiz;
  423. switch (wMsg) {
  424. case WM_DESTROY:
  425. hicon = (HICON)LOWORD(SendDlgItemMessage(hDlg,IDC_CLASSICON,STM_GETICON,0,0));
  426. if (hicon) {
  427. DestroyIcon(hicon);
  428. }
  429. break;
  430. case WUM_RESOURCEPICKER:
  431. {
  432. TCHAR Title[MAX_PATH], Message[MAX_PATH];
  433. LoadString(hHdwWiz, IDS_HDWWIZNAME, Title, SIZECHARS(Title));
  434. LoadString(hHdwWiz, IDS_NEED_FORCED_CONFIG, Message, SIZECHARS(Message));
  435. MessageBox(hDlg, Message, Title, MB_OK | MB_ICONEXCLAMATION);
  436. DisplayResource(HardwareWiz, GetParent(hDlg), TRUE);
  437. }
  438. break;
  439. case WM_NOTIFY:
  440. switch (((NMHDR FAR *)lParam)->code) {
  441. case PSN_SETACTIVE: {
  442. int PrevPage;
  443. DWORD RegisterError = ERROR_SUCCESS;
  444. SP_DRVINFO_DATA DriverInfoData;
  445. PrevPage = HardwareWiz->PrevPage;
  446. HardwareWiz->PrevPage = IDD_ADDDEVICE_ANALYZEDEV;
  447. if (PrevPage == IDD_WIZARDEXT_POSTANALYZE) {
  448. break;
  449. }
  450. //
  451. // Get info on currently selected device, since this could change
  452. // as the user move back and forth between wizard pages
  453. // we do this on each activate.
  454. //
  455. if (!SetupDiGetSelectedDevice(HardwareWiz->hDeviceInfo,
  456. &HardwareWiz->DeviceInfoData
  457. )) {
  458. RegisterError = GetLastError();
  459. } else {
  460. //
  461. // If wizard type is addnew, then we have a phantom devnode
  462. // and it needs to registered. All other wizard types, the
  463. // devnode is already registered.
  464. //
  465. RegisterError = RegisterDeviceNode(hDlg, HardwareWiz);
  466. }
  467. //
  468. // Set the class Icon
  469. //
  470. if (SetupDiLoadClassIcon(&HardwareWiz->DeviceInfoData.ClassGuid, &hicon, NULL)) {
  471. hicon = (HICON)SendDlgItemMessage(hDlg, IDC_CLASSICON, STM_SETICON, (WPARAM)hicon, 0L);
  472. if (hicon) {
  473. DestroyIcon(hicon);
  474. }
  475. }
  476. SetDriverDescription(hDlg, IDC_HDW_DESCRIPTION, HardwareWiz);
  477. PropSheet_SetWizButtons(hwndParentDlg, PSWIZB_BACK | PSWIZB_NEXT);
  478. //
  479. // need to determine conflict warning.
  480. //
  481. if (RegisterError != ERROR_SUCCESS) {
  482. //
  483. // Show the bullet text items.
  484. //
  485. ShowWindow(GetDlgItem(hDlg, IDC_BULLET_1), SW_SHOW);
  486. ShowWindow(GetDlgItem(hDlg, IDC_ANALYZE_INSTALL_TEXT), SW_SHOW);
  487. ShowWindow(GetDlgItem(hDlg, IDC_BULLET_2), SW_SHOW);
  488. ShowWindow(GetDlgItem(hDlg, IDC_ANALYZE_EXIT_TEXT), SW_SHOW);
  489. SetDlgText(hDlg, IDC_HDW_TEXT, IDS_HDW_ANALYZEERR1, IDS_HDW_ANALYZEERR1);
  490. //
  491. // Turn the 'i' character into a bullet.
  492. //
  493. SetWindowText(GetDlgItem(hDlg, IDC_BULLET_1), TEXT("i"));
  494. SetWindowFont(GetDlgItem(hDlg, IDC_BULLET_1), HardwareWiz->hfontTextMarlett, TRUE);
  495. SetWindowText(GetDlgItem(hDlg, IDC_BULLET_2), TEXT("i"));
  496. SetWindowFont(GetDlgItem(hDlg, IDC_BULLET_2), HardwareWiz->hfontTextMarlett, TRUE);
  497. if (RegisterError == ERROR_DUPLICATE_FOUND) {
  498. SetDlgText(hDlg, IDC_HDW_TEXT, IDS_HDW_DUPLICATE1, IDS_HDW_DUPLICATE1);
  499. }
  500. //
  501. // Bold the error text.
  502. //
  503. SetWindowFont(GetDlgItem(hDlg, IDC_HDW_TEXT), HardwareWiz->hfontTextBold, TRUE);
  504. } else {
  505. SetDlgText(hDlg, IDC_HDW_TEXT, IDS_HDW_STDCFG, IDS_HDW_STDCFG);
  506. //
  507. // Hide the bullet text items.
  508. //
  509. ShowWindow(GetDlgItem(hDlg, IDC_BULLET_1), SW_HIDE);
  510. ShowWindow(GetDlgItem(hDlg, IDC_ANALYZE_INSTALL_TEXT), SW_HIDE);
  511. ShowWindow(GetDlgItem(hDlg, IDC_BULLET_2), SW_HIDE);
  512. ShowWindow(GetDlgItem(hDlg, IDC_ANALYZE_EXIT_TEXT), SW_HIDE);
  513. }
  514. if (InstallWizard->DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED) {
  515. if (RegisterError == ERROR_SUCCESS ||
  516. !(InstallWizard->DynamicPageFlags & DYNAWIZ_FLAG_ANALYZE_HANDLECONFLICT)) {
  517. SetDlgMsgResult(hDlg, wMsg, IDD_DYNAWIZ_ANALYZE_NEXTPAGE);
  518. }
  519. }
  520. //
  521. // If a device has recources and it does not have a forced config
  522. // and it is a manually installed device then pop up the resource
  523. // picker. We need to do this because a legacy device must have
  524. // a forced or boot config or else it won't get started.
  525. //
  526. if ((ERROR_SUCCESS == RegisterError) &&
  527. !HardwareWiz->PnpDevice &&
  528. DeviceHasResources(HardwareWiz->DeviceInfoData.DevInst) &&
  529. !DeviceHasForcedConfig(HardwareWiz->DeviceInfoData.DevInst)) {
  530. //
  531. // Post ourselves a message to show the resource picker
  532. //
  533. PostMessage(hDlg, WUM_RESOURCEPICKER, 0, 0);
  534. }
  535. break;
  536. }
  537. case PSN_WIZBACK:
  538. //
  539. // Undo the registration
  540. //
  541. if (HardwareWiz->Registered) {
  542. HardwareWiz->Registered = FALSE;
  543. }
  544. if (HardwareWiz->WizExtPostAnalyze.hPropSheet) {
  545. PropSheet_RemovePage(hwndParentDlg,
  546. (WPARAM)-1,
  547. HardwareWiz->WizExtPostAnalyze.hPropSheet
  548. );
  549. HardwareWiz->WizExtPostAnalyze.hPropSheet = NULL;
  550. }
  551. SetDlgMsgResult(hDlg, wMsg, IDD_WIZARDEXT_PREANALYZE);
  552. break;
  553. case PSN_WIZNEXT:
  554. if (!HardwareWiz->Registered &&
  555. !SetupDiRegisterDeviceInfo(HardwareWiz->hDeviceInfo,
  556. &HardwareWiz->DeviceInfoData,
  557. 0,
  558. NULL,
  559. NULL,
  560. NULL
  561. ))
  562. {
  563. InstallFailedWarning(hDlg, HardwareWiz);
  564. if (HardwareWiz->WizExtPostAnalyze.hPropSheet) {
  565. PropSheet_RemovePage(hwndParentDlg,
  566. (WPARAM)-1,
  567. HardwareWiz->WizExtPostAnalyze.hPropSheet
  568. );
  569. HardwareWiz->WizExtPostAnalyze.hPropSheet = NULL;
  570. }
  571. SetDlgMsgResult(hDlg, wMsg, IDD_WIZARDEXT_PREANALYZE);
  572. }
  573. else {
  574. //
  575. // Add the PostAnalyze Page and jump to it
  576. //
  577. HardwareWiz->WizExtPostAnalyze.hPropSheet = CreateWizExtPage(IDD_WIZARDEXT_POSTANALYZE,
  578. WizExtPostAnalyzeDlgProc,
  579. HardwareWiz
  580. );
  581. if (HardwareWiz->WizExtPostAnalyze.hPropSheet) {
  582. PropSheet_AddPage(hwndParentDlg, HardwareWiz->WizExtPostAnalyze.hPropSheet);
  583. }
  584. SetDlgMsgResult(hDlg, wMsg, IDD_WIZARDEXT_POSTANALYZE);
  585. }
  586. break;
  587. }
  588. break;
  589. default:
  590. return(FALSE);
  591. }
  592. return(TRUE);
  593. }
  594. INT_PTR CALLBACK
  595. WizExtPreAnalyzeDlgProc(
  596. HWND hDlg,
  597. UINT wMsg,
  598. WPARAM wParam,
  599. LPARAM lParam
  600. )
  601. {
  602. HWND hwndParentDlg = GetParent(hDlg);
  603. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  604. int PrevPageId;
  605. switch (wMsg) {
  606. case WM_INITDIALOG: {
  607. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  608. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  609. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  610. break;
  611. }
  612. case WM_DESTROY:
  613. break;
  614. case WM_NOTIFY:
  615. switch (((NMHDR FAR *)lParam)->code) {
  616. case PSN_SETACTIVE:
  617. PrevPageId = HardwareWiz->PrevPage;
  618. HardwareWiz->PrevPage = IDD_WIZARDEXT_PREANALYZE;
  619. if (PrevPageId == IDD_WIZARDEXT_SELECT) {
  620. //
  621. // Moving forward on first page
  622. //
  623. //
  624. // if we are not doing the old fashioned DYNAWIZ
  625. // Add ClassWizard Extension pages for preanalyze
  626. //
  627. if (!(HardwareWiz->InstallDynaWiz.DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED))
  628. {
  629. AddClassWizExtPages(hwndParentDlg,
  630. HardwareWiz,
  631. &HardwareWiz->WizExtPreAnalyze.DeviceWizardData,
  632. DIF_NEWDEVICEWIZARD_PREANALYZE
  633. );
  634. }
  635. //
  636. // Add the end page, which is PreAnalyze end
  637. //
  638. HardwareWiz->WizExtPreAnalyze.hPropSheetEnd = CreateWizExtPage(IDD_WIZARDEXT_PREANALYZE_END,
  639. WizExtPreAnalyzeEndDlgProc,
  640. HardwareWiz
  641. );
  642. if (HardwareWiz->WizExtPreAnalyze.hPropSheetEnd) {
  643. PropSheet_AddPage(hwndParentDlg, HardwareWiz->WizExtPreAnalyze.hPropSheetEnd);
  644. }
  645. PropSheet_PressButton(hwndParentDlg, PSBTN_NEXT);
  646. }
  647. else {
  648. //
  649. // Moving backwards from PreAnalyze end on PreAanalyze
  650. //
  651. //
  652. // Clean up proppages added.
  653. //
  654. if (HardwareWiz->WizExtPreAnalyze.hPropSheetEnd) {
  655. PropSheet_RemovePage(hwndParentDlg,
  656. (WPARAM)-1,
  657. HardwareWiz->WizExtPreAnalyze.hPropSheetEnd
  658. );
  659. HardwareWiz->WizExtPreAnalyze.hPropSheetEnd = NULL;
  660. }
  661. RemoveClassWizExtPages(hwndParentDlg,
  662. &HardwareWiz->WizExtPreAnalyze.DeviceWizardData
  663. );
  664. //
  665. // Jump back
  666. // Note: The target pages don't set PrevPage, so set it for them
  667. //
  668. HardwareWiz->PrevPage = IDD_WIZARDEXT_SELECT;
  669. if (HardwareWiz->InstallDynaWiz.DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED) {
  670. SetDlgMsgResult(hDlg, wMsg, IDD_DYNAWIZ_ANALYZE_PREVPAGE);
  671. }
  672. else {
  673. SetDlgMsgResult(hDlg, wMsg, IDD_DYNAWIZ_SELECTDEV_PAGE);
  674. }
  675. }
  676. break;
  677. case PSN_WIZNEXT:
  678. SetDlgMsgResult(hDlg, wMsg, 0);
  679. break;
  680. }
  681. break;
  682. default:
  683. return(FALSE);
  684. }
  685. return(TRUE);
  686. }
  687. INT_PTR CALLBACK
  688. WizExtPreAnalyzeEndDlgProc(
  689. HWND hDlg,
  690. UINT wMsg,
  691. WPARAM wParam,
  692. LPARAM lParam
  693. )
  694. {
  695. HWND hwndParentDlg = GetParent(hDlg);
  696. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  697. int PrevPageId;
  698. switch (wMsg) {
  699. case WM_INITDIALOG: {
  700. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  701. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  702. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  703. break;
  704. }
  705. case WM_DESTROY:
  706. break;
  707. case WM_NOTIFY:
  708. switch (((NMHDR FAR *)lParam)->code) {
  709. case PSN_SETACTIVE:
  710. PrevPageId = HardwareWiz->PrevPage;
  711. HardwareWiz->PrevPage = IDD_WIZARDEXT_PREANALYZE_END;
  712. if (PrevPageId == IDD_ADDDEVICE_ANALYZEDEV) {
  713. //
  714. // Moving backwards from analyzepage
  715. //
  716. //
  717. // Jump back
  718. //
  719. PropSheet_PressButton(hwndParentDlg, PSBTN_BACK);
  720. }
  721. else {
  722. //
  723. // Moving forward on end page
  724. //
  725. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_ANALYZEDEV);
  726. }
  727. break;
  728. case PSN_WIZBACK:
  729. case PSN_WIZNEXT:
  730. SetDlgMsgResult(hDlg, wMsg, 0);
  731. break;
  732. }
  733. break;
  734. default:
  735. return(FALSE);
  736. }
  737. return(TRUE);
  738. }
  739. INT_PTR CALLBACK
  740. WizExtPostAnalyzeDlgProc(
  741. HWND hDlg,
  742. UINT wMsg,
  743. WPARAM wParam,
  744. LPARAM lParam
  745. )
  746. {
  747. HWND hwndParentDlg = GetParent(hDlg);
  748. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  749. int PrevPageId;
  750. switch (wMsg) {
  751. case WM_INITDIALOG: {
  752. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  753. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  754. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  755. break;
  756. }
  757. case WM_DESTROY:
  758. break;
  759. case WM_NOTIFY:
  760. switch (((NMHDR FAR *)lParam)->code) {
  761. case PSN_SETACTIVE:
  762. PrevPageId = HardwareWiz->PrevPage;
  763. HardwareWiz->PrevPage = IDD_WIZARDEXT_POSTANALYZE;
  764. if (PrevPageId == IDD_ADDDEVICE_ANALYZEDEV) {
  765. //
  766. // Moving forward on first page
  767. //
  768. //
  769. // if we are not doing the old fashioned DYNAWIZ
  770. // Add ClassWizard Extension pages for postanalyze
  771. //
  772. if (!(HardwareWiz->InstallDynaWiz.DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED))
  773. {
  774. AddClassWizExtPages(hwndParentDlg,
  775. HardwareWiz,
  776. &HardwareWiz->WizExtPostAnalyze.DeviceWizardData,
  777. DIF_NEWDEVICEWIZARD_POSTANALYZE
  778. );
  779. }
  780. //
  781. // Add the end page, which is PostAnalyze end
  782. //
  783. HardwareWiz->WizExtPostAnalyze.hPropSheetEnd = CreateWizExtPage(IDD_WIZARDEXT_POSTANALYZE_END,
  784. WizExtPostAnalyzeEndDlgProc,
  785. HardwareWiz
  786. );
  787. if (HardwareWiz->WizExtPostAnalyze.hPropSheetEnd) {
  788. PropSheet_AddPage(hwndParentDlg, HardwareWiz->WizExtPostAnalyze.hPropSheetEnd);
  789. }
  790. PropSheet_PressButton(hwndParentDlg, PSBTN_NEXT);
  791. }
  792. else {
  793. //
  794. // Moving backwards from PostAnalyze end on PostAnalyze
  795. //
  796. //
  797. // Clean up proppages added.
  798. //
  799. if (HardwareWiz->WizExtPostAnalyze.hPropSheetEnd) {
  800. PropSheet_RemovePage(hwndParentDlg,
  801. (WPARAM)-1,
  802. HardwareWiz->WizExtPostAnalyze.hPropSheetEnd
  803. );
  804. HardwareWiz->WizExtPostAnalyze.hPropSheetEnd = NULL;
  805. }
  806. RemoveClassWizExtPages(hwndParentDlg,
  807. &HardwareWiz->WizExtPostAnalyze.DeviceWizardData
  808. );
  809. }
  810. break;
  811. case PSN_WIZBACK:
  812. case PSN_WIZNEXT:
  813. SetDlgMsgResult(hDlg, wMsg, 0);
  814. break;
  815. }
  816. break;
  817. default:
  818. return(FALSE);
  819. }
  820. return(TRUE);
  821. }
  822. INT_PTR CALLBACK
  823. WizExtPostAnalyzeEndDlgProc(
  824. HWND hDlg,
  825. UINT wMsg,
  826. WPARAM wParam,
  827. LPARAM lParam
  828. )
  829. {
  830. HWND hwndParentDlg = GetParent(hDlg);
  831. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  832. int PrevPageId;
  833. switch (wMsg) {
  834. case WM_INITDIALOG: {
  835. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  836. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  837. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  838. break;
  839. }
  840. case WM_DESTROY:
  841. break;
  842. case WM_NOTIFY:
  843. switch (((NMHDR FAR *)lParam)->code) {
  844. case PSN_SETACTIVE:
  845. PrevPageId = HardwareWiz->PrevPage;
  846. HardwareWiz->PrevPage = IDD_WIZARDEXT_POSTANALYZE_END;
  847. if (PrevPageId == IDD_ADDDEVICE_INSTALLDEV) {
  848. //
  849. // Moving backwards from finishpage
  850. //
  851. //
  852. // Jump back
  853. //
  854. PropSheet_PressButton(hwndParentDlg, PSBTN_BACK);
  855. }
  856. else {
  857. //
  858. // Moving forward on End page
  859. //
  860. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_INSTALLDEV);
  861. }
  862. break;
  863. case PSN_WIZBACK:
  864. case PSN_WIZNEXT:
  865. SetDlgMsgResult(hDlg, wMsg, 0);
  866. break;
  867. }
  868. break;
  869. default:
  870. return(FALSE);
  871. }
  872. return(TRUE);
  873. }