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.

1144 lines
34 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. UNREFERENCED_PARAMETER(wParam);
  39. switch (wMsg) {
  40. case WM_INITDIALOG: {
  41. HICON hIcon;
  42. HWND hwndParentDlg;
  43. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  44. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  45. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  46. hIcon = LoadIcon(hHdwWiz,MAKEINTRESOURCE(IDI_HDWWIZICON));
  47. if (hIcon) {
  48. hwndParentDlg = GetParent(hDlg);
  49. SendMessage(hwndParentDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
  50. SendMessage(hwndParentDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
  51. }
  52. break;
  53. }
  54. case WM_COMMAND:
  55. break;
  56. case WM_NOTIFY:
  57. switch (((NMHDR FAR *)lParam)->code) {
  58. case PSN_SETACTIVE: {
  59. int PrevPage;
  60. PrevPage = HardwareWiz->PrevPage;
  61. HardwareWiz->PrevPage = IDD_INSTALLNEWDEVICE;
  62. //
  63. // If we are coming back then this is effectively a Cancel
  64. // of the install.
  65. //
  66. if (PrevPage == IDD_ADDDEVICE_SELECTDEVICE ||
  67. PrevPage == IDD_ADDDEVICE_SELECTCLASS )
  68. {
  69. PropSheet_PressButton(GetParent(hDlg), PSBTN_CANCEL);
  70. break;
  71. }
  72. //
  73. // If we have a class then jump into SelectDevice.
  74. // otherwise goto search pages.
  75. //
  76. if (HardwareWiz->ClassGuidSelected) {
  77. HardwareWiz->EnterInto = IDD_ADDDEVICE_SELECTDEVICE;
  78. HardwareWiz->EnterFrom = IDD_INSTALLNEWDEVICE;
  79. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_SELECTDEVICE);
  80. } else {
  81. HardwareWiz->EnterInto = IDD_ADDDEVICE_SELECTCLASS;
  82. HardwareWiz->EnterFrom = IDD_INSTALLNEWDEVICE;
  83. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_SELECTCLASS);
  84. }
  85. }
  86. break;
  87. case PSN_WIZNEXT:
  88. break;
  89. case PSN_RESET:
  90. HardwareWiz->Cancelled = TRUE;
  91. break;
  92. }
  93. break;
  94. default:
  95. return(FALSE);
  96. }
  97. return(TRUE);
  98. }
  99. BOOL
  100. CompareInfIdToHardwareIds(
  101. LPTSTR HardwareId,
  102. LPTSTR InfDeviceId
  103. )
  104. /*++
  105. This function takes a pointer to the Hardware/Compatible Id list for a device and
  106. a DeviceId that we got from the INF. It enumerates through all of the device's
  107. Hardware and Compatible Ids comparing them against the Device Id we got from the INF.
  108. If one of the device's Hardware or Compatible Ids match the API returns TRUE, otherwise
  109. it returns FALSE.
  110. --*/
  111. {
  112. while (*HardwareId) {
  113. if (_wcsicmp(HardwareId, InfDeviceId) == 0) {
  114. return TRUE;
  115. }
  116. HardwareId = HardwareId + lstrlen(HardwareId) + 1;
  117. }
  118. return(FALSE);
  119. }
  120. /*
  121. * RegisterDeviceNode
  122. *
  123. * Determines if device is a legacy or pnp style device,
  124. * Registers the device (phantomn devnode to real devnode).
  125. *
  126. */
  127. DWORD
  128. RegisterDeviceNode(
  129. HWND hDlg,
  130. PHARDWAREWIZ HardwareWiz
  131. )
  132. {
  133. DWORD FieldCount, Index, Len;
  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->CopyFilesOnly= 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. SIZECHARS(InfDeviceID),
  224. NULL
  225. ))
  226. {
  227. if (CompareInfIdToHardwareIds(HardwareId, InfDeviceID)) {
  228. HardwareWiz->CopyFilesOnly = 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. SUCCEEDED(StringCchCat(SectionName,
  250. SIZECHARS(SectionName),
  251. TEXT(".") INFSTR_SUBKEY_FACTDEF)) &&
  252. (SetupFindFirstLine(hInf, SectionName, NULL, &InfContext))) {
  253. SetupInstallFromInfSection(hDlg,
  254. hInf,
  255. SectionName,
  256. SPINST_LOGCONFIG | SPINST_SINGLESECTION | SPINST_LOGCONFIG_IS_FORCED,
  257. NULL,
  258. NULL,
  259. 0,
  260. NULL,
  261. NULL,
  262. HardwareWiz->hDeviceInfo,
  263. &HardwareWiz->DeviceInfoData
  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 Len;
  297. HINF hInf = INVALID_HANDLE_VALUE;
  298. SP_DRVINFO_DATA DriverInfoData;
  299. PSP_DRVINFO_DETAIL_DATA DriverInfoDetailData = NULL;
  300. TCHAR SectionName[LINE_LEN*2];
  301. LONG LastError = ERROR_SUCCESS;
  302. //
  303. // Fetch the DriverInfoDetail, with enough space for lots of hardwareIDs.
  304. //
  305. Len = sizeof(SP_DRVINFO_DETAIL_DATA) + MAX_PATH*sizeof(TCHAR);
  306. DriverInfoDetailData = LocalAlloc(LPTR, Len);
  307. if (!DriverInfoDetailData) {
  308. goto AnalyzeExit;
  309. }
  310. DriverInfoDetailData->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);
  311. DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
  312. if (!SetupDiGetSelectedDriver(HardwareWiz->hDeviceInfo,
  313. &HardwareWiz->DeviceInfoData,
  314. &DriverInfoData
  315. ))
  316. {
  317. goto AnalyzeExit;
  318. }
  319. if (!SetupDiGetDriverInfoDetail(HardwareWiz->hDeviceInfo,
  320. &HardwareWiz->DeviceInfoData,
  321. &DriverInfoData,
  322. DriverInfoDetailData,
  323. Len,
  324. &Len
  325. ))
  326. {
  327. if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
  328. LocalFree(DriverInfoDetailData);
  329. DriverInfoDetailData = LocalAlloc(LPTR, Len);
  330. if (!DriverInfoDetailData) {
  331. goto AnalyzeExit;
  332. }
  333. DriverInfoDetailData->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);
  334. if (!SetupDiGetDriverInfoDetail(HardwareWiz->hDeviceInfo,
  335. &HardwareWiz->DeviceInfoData,
  336. &DriverInfoData,
  337. DriverInfoDetailData,
  338. Len,
  339. NULL
  340. ))
  341. {
  342. goto AnalyzeExit;
  343. }
  344. } else {
  345. goto AnalyzeExit;
  346. }
  347. }
  348. //
  349. // Get a handle to the inf file.
  350. //
  351. hInf = SetupOpenInfFile(DriverInfoDetailData->InfFileName,
  352. NULL,
  353. INF_STYLE_WIN4,
  354. NULL
  355. );
  356. if (hInf == INVALID_HANDLE_VALUE) {
  357. //
  358. // If this is an old style inf file, then we can't write out
  359. // the logconfigs for classes which allow old style infs this is Ok,
  360. // If its an invalid or missing inf, it will fail further
  361. // down the chain of execution
  362. //
  363. goto AnalyzeExit;
  364. }
  365. //
  366. // Install any LogConfig entries in the install section.
  367. //
  368. if (SetupDiGetActualSectionToInstall(hInf,
  369. DriverInfoDetailData->SectionName,
  370. SectionName,
  371. SIZECHARS(SectionName),
  372. NULL,
  373. NULL
  374. ))
  375. {
  376. SetupInstallFromInfSection(hDlg,
  377. hInf,
  378. SectionName,
  379. SPINST_LOGCONFIG,
  380. NULL,
  381. NULL,
  382. 0,
  383. NULL,
  384. NULL,
  385. HardwareWiz->hDeviceInfo,
  386. &HardwareWiz->DeviceInfoData
  387. );
  388. }
  389. AnalyzeExit:
  390. if (DriverInfoDetailData) {
  391. LocalFree(DriverInfoDetailData);
  392. }
  393. if (hInf != INVALID_HANDLE_VALUE) {
  394. SetupCloseInfFile(hInf);
  395. }
  396. return LastError;
  397. }
  398. INT_PTR CALLBACK
  399. HdwAnalyzeDlgProc(
  400. HWND hDlg,
  401. UINT wMsg,
  402. WPARAM wParam,
  403. LPARAM lParam
  404. )
  405. {
  406. HICON hicon;
  407. HWND hwndParentDlg = GetParent(hDlg);
  408. PHARDWAREWIZ HardwareWiz;
  409. PSP_INSTALLWIZARD_DATA InstallWizard;
  410. UNREFERENCED_PARAMETER(wParam);
  411. if (wMsg == WM_INITDIALOG) {
  412. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  413. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  414. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  415. HardwareWiz->AnalyzeResult = 0;
  416. return TRUE;
  417. }
  418. HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  419. InstallWizard = &HardwareWiz->InstallDynaWiz;
  420. switch (wMsg) {
  421. case WM_DESTROY:
  422. hicon = (HICON)SendDlgItemMessage(hDlg,IDC_CLASSICON,STM_GETICON,0,0);
  423. if (hicon) {
  424. DestroyIcon(hicon);
  425. }
  426. break;
  427. case WUM_RESOURCEPICKER:
  428. {
  429. TCHAR Title[MAX_PATH], Message[MAX_PATH];
  430. LoadString(hHdwWiz, IDS_HDWWIZNAME, Title, SIZECHARS(Title));
  431. LoadString(hHdwWiz, IDS_NEED_FORCED_CONFIG, Message, SIZECHARS(Message));
  432. MessageBox(hDlg, Message, Title, MB_OK | MB_ICONEXCLAMATION);
  433. DisplayResource(HardwareWiz, GetParent(hDlg), TRUE);
  434. }
  435. break;
  436. case WM_NOTIFY:
  437. switch (((NMHDR FAR *)lParam)->code) {
  438. case PSN_SETACTIVE: {
  439. int PrevPage;
  440. DWORD RegisterError = ERROR_SUCCESS;
  441. PrevPage = HardwareWiz->PrevPage;
  442. HardwareWiz->PrevPage = IDD_ADDDEVICE_ANALYZEDEV;
  443. if (PrevPage == IDD_WIZARDEXT_POSTANALYZE) {
  444. break;
  445. }
  446. //
  447. // Get info on currently selected device, since this could change
  448. // as the user move back and forth between wizard pages
  449. // we do this on each activate.
  450. //
  451. if (!SetupDiGetSelectedDevice(HardwareWiz->hDeviceInfo,
  452. &HardwareWiz->DeviceInfoData
  453. )) {
  454. RegisterError = GetLastError();
  455. } else {
  456. //
  457. // If wizard type is addnew, then we have a phantom devnode
  458. // and it needs to registered. All other wizard types, the
  459. // devnode is already registered.
  460. //
  461. RegisterError = RegisterDeviceNode(hDlg, HardwareWiz);
  462. }
  463. //
  464. // Set the class Icon
  465. //
  466. if (SetupDiLoadClassIcon(&HardwareWiz->DeviceInfoData.ClassGuid, &hicon, NULL)) {
  467. hicon = (HICON)SendDlgItemMessage(hDlg, IDC_CLASSICON, STM_SETICON, (WPARAM)hicon, 0L);
  468. if (hicon) {
  469. DestroyIcon(hicon);
  470. }
  471. }
  472. SetDriverDescription(hDlg, IDC_HDW_DESCRIPTION, HardwareWiz);
  473. PropSheet_SetWizButtons(hwndParentDlg, PSWIZB_BACK | PSWIZB_NEXT);
  474. //
  475. // need to determine conflict warning.
  476. //
  477. if (RegisterError != ERROR_SUCCESS) {
  478. //
  479. // Show the bullet text items.
  480. //
  481. ShowWindow(GetDlgItem(hDlg, IDC_BULLET_1), SW_SHOW);
  482. ShowWindow(GetDlgItem(hDlg, IDC_ANALYZE_INSTALL_TEXT), SW_SHOW);
  483. ShowWindow(GetDlgItem(hDlg, IDC_BULLET_2), SW_SHOW);
  484. ShowWindow(GetDlgItem(hDlg, IDC_ANALYZE_EXIT_TEXT), SW_SHOW);
  485. SetDlgText(hDlg, IDC_HDW_TEXT, IDS_HDW_ANALYZEERR1, IDS_HDW_ANALYZEERR1);
  486. //
  487. // Turn the 'i' character into a bullet.
  488. //
  489. SetWindowText(GetDlgItem(hDlg, IDC_BULLET_1), TEXT("i"));
  490. SetWindowFont(GetDlgItem(hDlg, IDC_BULLET_1), HardwareWiz->hfontTextMarlett, TRUE);
  491. SetWindowText(GetDlgItem(hDlg, IDC_BULLET_2), TEXT("i"));
  492. SetWindowFont(GetDlgItem(hDlg, IDC_BULLET_2), HardwareWiz->hfontTextMarlett, TRUE);
  493. if (RegisterError == ERROR_DUPLICATE_FOUND) {
  494. SetDlgText(hDlg, IDC_HDW_TEXT, IDS_HDW_DUPLICATE1, IDS_HDW_DUPLICATE1);
  495. }
  496. //
  497. // Bold the error text.
  498. //
  499. SetWindowFont(GetDlgItem(hDlg, IDC_HDW_TEXT), HardwareWiz->hfontTextBold, TRUE);
  500. } else {
  501. SetDlgText(hDlg, IDC_HDW_TEXT, IDS_HDW_STDCFG, IDS_HDW_STDCFG);
  502. //
  503. // Hide the bullet text items.
  504. //
  505. ShowWindow(GetDlgItem(hDlg, IDC_BULLET_1), SW_HIDE);
  506. ShowWindow(GetDlgItem(hDlg, IDC_ANALYZE_INSTALL_TEXT), SW_HIDE);
  507. ShowWindow(GetDlgItem(hDlg, IDC_BULLET_2), SW_HIDE);
  508. ShowWindow(GetDlgItem(hDlg, IDC_ANALYZE_EXIT_TEXT), SW_HIDE);
  509. }
  510. if (InstallWizard->DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED) {
  511. if (RegisterError == ERROR_SUCCESS ||
  512. !(InstallWizard->DynamicPageFlags & DYNAWIZ_FLAG_ANALYZE_HANDLECONFLICT)) {
  513. SetDlgMsgResult(hDlg, wMsg, IDD_DYNAWIZ_ANALYZE_NEXTPAGE);
  514. }
  515. }
  516. //
  517. // If a device has recources and it does not have a forced config
  518. // and it is a manually installed device then pop up the resource
  519. // picker. We need to do this because a legacy device must have
  520. // a forced or boot config or else it won't get started.
  521. //
  522. if ((ERROR_SUCCESS == RegisterError) &&
  523. !HardwareWiz->CopyFilesOnly &&
  524. DeviceHasResources(HardwareWiz->DeviceInfoData.DevInst) &&
  525. !DeviceHasForcedConfig(HardwareWiz->DeviceInfoData.DevInst)) {
  526. //
  527. // Post ourselves a message to show the resource picker
  528. //
  529. PostMessage(hDlg, WUM_RESOURCEPICKER, 0, 0);
  530. }
  531. break;
  532. }
  533. case PSN_WIZBACK:
  534. //
  535. // Undo the registration
  536. //
  537. if (HardwareWiz->Registered) {
  538. HardwareWiz->Registered = FALSE;
  539. }
  540. if (HardwareWiz->WizExtPostAnalyze.hPropSheet) {
  541. PropSheet_RemovePage(hwndParentDlg,
  542. (WPARAM)-1,
  543. HardwareWiz->WizExtPostAnalyze.hPropSheet
  544. );
  545. HardwareWiz->WizExtPostAnalyze.hPropSheet = NULL;
  546. }
  547. SetDlgMsgResult(hDlg, wMsg, IDD_WIZARDEXT_PREANALYZE);
  548. break;
  549. case PSN_WIZNEXT:
  550. if (!HardwareWiz->Registered &&
  551. !SetupDiRegisterDeviceInfo(HardwareWiz->hDeviceInfo,
  552. &HardwareWiz->DeviceInfoData,
  553. 0,
  554. NULL,
  555. NULL,
  556. NULL
  557. ))
  558. {
  559. InstallFailedWarning(hDlg, HardwareWiz);
  560. if (HardwareWiz->WizExtPostAnalyze.hPropSheet) {
  561. PropSheet_RemovePage(hwndParentDlg,
  562. (WPARAM)-1,
  563. HardwareWiz->WizExtPostAnalyze.hPropSheet
  564. );
  565. HardwareWiz->WizExtPostAnalyze.hPropSheet = NULL;
  566. }
  567. SetDlgMsgResult(hDlg, wMsg, IDD_WIZARDEXT_PREANALYZE);
  568. }
  569. else {
  570. //
  571. // Add the PostAnalyze Page and jump to it
  572. //
  573. HardwareWiz->WizExtPostAnalyze.hPropSheet = CreateWizExtPage(IDD_WIZARDEXT_POSTANALYZE,
  574. WizExtPostAnalyzeDlgProc,
  575. HardwareWiz
  576. );
  577. if (HardwareWiz->WizExtPostAnalyze.hPropSheet) {
  578. PropSheet_AddPage(hwndParentDlg, HardwareWiz->WizExtPostAnalyze.hPropSheet);
  579. }
  580. SetDlgMsgResult(hDlg, wMsg, IDD_WIZARDEXT_POSTANALYZE);
  581. }
  582. break;
  583. }
  584. break;
  585. default:
  586. return(FALSE);
  587. }
  588. return(TRUE);
  589. }
  590. INT_PTR CALLBACK
  591. WizExtPreAnalyzeDlgProc(
  592. HWND hDlg,
  593. UINT wMsg,
  594. WPARAM wParam,
  595. LPARAM lParam
  596. )
  597. {
  598. HWND hwndParentDlg = GetParent(hDlg);
  599. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  600. int PrevPageId;
  601. UNREFERENCED_PARAMETER(wParam);
  602. switch (wMsg) {
  603. case WM_INITDIALOG: {
  604. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  605. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  606. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  607. break;
  608. }
  609. case WM_DESTROY:
  610. break;
  611. case WM_NOTIFY:
  612. switch (((NMHDR FAR *)lParam)->code) {
  613. case PSN_SETACTIVE:
  614. PrevPageId = HardwareWiz->PrevPage;
  615. HardwareWiz->PrevPage = IDD_WIZARDEXT_PREANALYZE;
  616. if (PrevPageId == IDD_WIZARDEXT_SELECT) {
  617. //
  618. // Moving forward on first page
  619. //
  620. //
  621. // if we are not doing the old fashioned DYNAWIZ
  622. // Add ClassWizard Extension pages for preanalyze
  623. //
  624. if (!(HardwareWiz->InstallDynaWiz.DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED))
  625. {
  626. AddClassWizExtPages(hwndParentDlg,
  627. HardwareWiz,
  628. &HardwareWiz->WizExtPreAnalyze.DeviceWizardData,
  629. DIF_NEWDEVICEWIZARD_PREANALYZE
  630. );
  631. }
  632. //
  633. // Add the end page, which is PreAnalyze end
  634. //
  635. HardwareWiz->WizExtPreAnalyze.hPropSheetEnd = CreateWizExtPage(IDD_WIZARDEXT_PREANALYZE_END,
  636. WizExtPreAnalyzeEndDlgProc,
  637. HardwareWiz
  638. );
  639. if (HardwareWiz->WizExtPreAnalyze.hPropSheetEnd) {
  640. PropSheet_AddPage(hwndParentDlg, HardwareWiz->WizExtPreAnalyze.hPropSheetEnd);
  641. }
  642. PropSheet_PressButton(hwndParentDlg, PSBTN_NEXT);
  643. }
  644. else {
  645. //
  646. // Moving backwards from PreAnalyze end on PreAanalyze
  647. //
  648. //
  649. // Clean up proppages added.
  650. //
  651. if (HardwareWiz->WizExtPreAnalyze.hPropSheetEnd) {
  652. PropSheet_RemovePage(hwndParentDlg,
  653. (WPARAM)-1,
  654. HardwareWiz->WizExtPreAnalyze.hPropSheetEnd
  655. );
  656. HardwareWiz->WizExtPreAnalyze.hPropSheetEnd = NULL;
  657. }
  658. RemoveClassWizExtPages(hwndParentDlg,
  659. &HardwareWiz->WizExtPreAnalyze.DeviceWizardData
  660. );
  661. //
  662. // Jump back
  663. // Note: The target pages don't set PrevPage, so set it for them
  664. //
  665. HardwareWiz->PrevPage = IDD_WIZARDEXT_SELECT;
  666. if (HardwareWiz->InstallDynaWiz.DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED) {
  667. SetDlgMsgResult(hDlg, wMsg, IDD_DYNAWIZ_ANALYZE_PREVPAGE);
  668. }
  669. else {
  670. SetDlgMsgResult(hDlg, wMsg, IDD_DYNAWIZ_SELECTDEV_PAGE);
  671. }
  672. }
  673. break;
  674. case PSN_WIZNEXT:
  675. SetDlgMsgResult(hDlg, wMsg, 0);
  676. break;
  677. }
  678. break;
  679. default:
  680. return(FALSE);
  681. }
  682. return(TRUE);
  683. }
  684. INT_PTR CALLBACK
  685. WizExtPreAnalyzeEndDlgProc(
  686. HWND hDlg,
  687. UINT wMsg,
  688. WPARAM wParam,
  689. LPARAM lParam
  690. )
  691. {
  692. HWND hwndParentDlg = GetParent(hDlg);
  693. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  694. int PrevPageId;
  695. UNREFERENCED_PARAMETER(wParam);
  696. switch (wMsg) {
  697. case WM_INITDIALOG: {
  698. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  699. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  700. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  701. break;
  702. }
  703. case WM_DESTROY:
  704. break;
  705. case WM_NOTIFY:
  706. switch (((NMHDR FAR *)lParam)->code) {
  707. case PSN_SETACTIVE:
  708. PrevPageId = HardwareWiz->PrevPage;
  709. HardwareWiz->PrevPage = IDD_WIZARDEXT_PREANALYZE_END;
  710. if (PrevPageId == IDD_ADDDEVICE_ANALYZEDEV) {
  711. //
  712. // Moving backwards from analyzepage
  713. //
  714. //
  715. // Jump back
  716. //
  717. PropSheet_PressButton(hwndParentDlg, PSBTN_BACK);
  718. }
  719. else {
  720. //
  721. // Moving forward on end page
  722. //
  723. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_ANALYZEDEV);
  724. }
  725. break;
  726. case PSN_WIZBACK:
  727. case PSN_WIZNEXT:
  728. SetDlgMsgResult(hDlg, wMsg, 0);
  729. break;
  730. }
  731. break;
  732. default:
  733. return(FALSE);
  734. }
  735. return(TRUE);
  736. }
  737. INT_PTR CALLBACK
  738. WizExtPostAnalyzeDlgProc(
  739. HWND hDlg,
  740. UINT wMsg,
  741. WPARAM wParam,
  742. LPARAM lParam
  743. )
  744. {
  745. HWND hwndParentDlg = GetParent(hDlg);
  746. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  747. int PrevPageId;
  748. UNREFERENCED_PARAMETER(wParam);
  749. switch (wMsg) {
  750. case WM_INITDIALOG: {
  751. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  752. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  753. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  754. break;
  755. }
  756. case WM_DESTROY:
  757. break;
  758. case WM_NOTIFY:
  759. switch (((NMHDR FAR *)lParam)->code) {
  760. case PSN_SETACTIVE:
  761. PrevPageId = HardwareWiz->PrevPage;
  762. HardwareWiz->PrevPage = IDD_WIZARDEXT_POSTANALYZE;
  763. if (PrevPageId == IDD_ADDDEVICE_ANALYZEDEV) {
  764. //
  765. // Moving forward on first page
  766. //
  767. //
  768. // if we are not doing the old fashioned DYNAWIZ
  769. // Add ClassWizard Extension pages for postanalyze
  770. //
  771. if (!(HardwareWiz->InstallDynaWiz.DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED))
  772. {
  773. AddClassWizExtPages(hwndParentDlg,
  774. HardwareWiz,
  775. &HardwareWiz->WizExtPostAnalyze.DeviceWizardData,
  776. DIF_NEWDEVICEWIZARD_POSTANALYZE
  777. );
  778. }
  779. //
  780. // Add the end page, which is PostAnalyze end
  781. //
  782. HardwareWiz->WizExtPostAnalyze.hPropSheetEnd = CreateWizExtPage(IDD_WIZARDEXT_POSTANALYZE_END,
  783. WizExtPostAnalyzeEndDlgProc,
  784. HardwareWiz
  785. );
  786. if (HardwareWiz->WizExtPostAnalyze.hPropSheetEnd) {
  787. PropSheet_AddPage(hwndParentDlg, HardwareWiz->WizExtPostAnalyze.hPropSheetEnd);
  788. }
  789. PropSheet_PressButton(hwndParentDlg, PSBTN_NEXT);
  790. }
  791. else {
  792. //
  793. // Moving backwards from PostAnalyze end on PostAnalyze
  794. //
  795. //
  796. // Clean up proppages added.
  797. //
  798. if (HardwareWiz->WizExtPostAnalyze.hPropSheetEnd) {
  799. PropSheet_RemovePage(hwndParentDlg,
  800. (WPARAM)-1,
  801. HardwareWiz->WizExtPostAnalyze.hPropSheetEnd
  802. );
  803. HardwareWiz->WizExtPostAnalyze.hPropSheetEnd = NULL;
  804. }
  805. RemoveClassWizExtPages(hwndParentDlg,
  806. &HardwareWiz->WizExtPostAnalyze.DeviceWizardData
  807. );
  808. }
  809. break;
  810. case PSN_WIZBACK:
  811. case PSN_WIZNEXT:
  812. SetDlgMsgResult(hDlg, wMsg, 0);
  813. break;
  814. }
  815. break;
  816. default:
  817. return(FALSE);
  818. }
  819. return(TRUE);
  820. }
  821. INT_PTR CALLBACK
  822. WizExtPostAnalyzeEndDlgProc(
  823. HWND hDlg,
  824. UINT wMsg,
  825. WPARAM wParam,
  826. LPARAM lParam
  827. )
  828. {
  829. HWND hwndParentDlg = GetParent(hDlg);
  830. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  831. int PrevPageId;
  832. UNREFERENCED_PARAMETER(wParam);
  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. }