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.

1114 lines
41 KiB

  1. #include "migwiz.h"
  2. #include "migwnprc.h"
  3. #include "migeng.h"
  4. #include "migutil.h"
  5. #include "miginf.h"
  6. #include "shellapi.h"
  7. #include "resource.h"
  8. HINSTANCE g_hInstance = NULL;
  9. BOOL g_fLastResponse; // did the user hit ok to the last callback message?
  10. extern MigrationWizard* g_migwiz;
  11. extern BOOL g_fHaveNet; // OLD COMPUTER ONLY: this means we can use the network
  12. extern BOOL g_fReadFromNetwork; // NEW COMPUTER ONLY: this means go ahead and read from the network immediately
  13. extern BOOL g_fStoreToNetwork; // OLD COMPUTER ONLY: this means we've selected to store to the network
  14. extern HWND g_hwndCurrent;
  15. extern CRITICAL_SECTION g_csDialogCritSection;
  16. extern CRITICAL_SECTION g_AppInfoCritSection;
  17. extern BOOL g_fUberCancel;
  18. DWORD g_HTMLErrArea = 0;
  19. DWORD g_HTMLErrInstr = 0;
  20. PCTSTR g_HTMLErrObjectType = NULL;
  21. PCTSTR g_HTMLErrObjectName = NULL;
  22. POBJLIST g_HTMLWrnFile = NULL;
  23. POBJLIST g_HTMLWrnAltFile = NULL;
  24. POBJLIST g_HTMLWrnRas = NULL;
  25. POBJLIST g_HTMLWrnNet = NULL;
  26. POBJLIST g_HTMLWrnPrn = NULL;
  27. POBJLIST g_HTMLWrnGeneral = NULL;
  28. TCHAR g_szMultiDests[20 * MAX_PATH];
  29. BOOL g_fReceivedMultiDest = FALSE; // we only respond to the first multi-dest message we receive
  30. extern MIG_PROGRESSPHASE g_AppInfoPhase;
  31. extern UINT g_AppInfoSubPhase;
  32. extern MIG_OBJECTTYPEID g_AppInfoObjectTypeId;
  33. extern TCHAR g_AppInfoObjectName [4096];
  34. extern TCHAR g_AppInfoText [4096];
  35. MigrationWizard::MigrationWizard() : _fInit(FALSE), _pszUsername(NULL)
  36. {
  37. }
  38. MigrationWizard::~MigrationWizard()
  39. {
  40. CloseAppInf();
  41. // Destroy the fonts
  42. if (_hTitleFont)
  43. {
  44. DeleteObject(_hTitleFont);
  45. DeleteObject(_h95HeaderFont);
  46. }
  47. if (_pszUsername)
  48. {
  49. LocalFree(_pszUsername);
  50. }
  51. if (_fDelCs) {
  52. DeleteCriticalSection (&g_csDialogCritSection);
  53. _fDelCs = FALSE;
  54. }
  55. }
  56. HRESULT MigrationWizard::Init(HINSTANCE hInstance, LPTSTR pszUsername)
  57. {
  58. HRESULT hr;
  59. BOOL fWinXP = FALSE;
  60. _hInstance = hInstance;
  61. if (pszUsername)
  62. {
  63. _pszUsername = (LPTSTR)LocalAlloc(LPTR, (lstrlen(pszUsername) + 1) * sizeof (TCHAR));
  64. if (_pszUsername)
  65. {
  66. lstrcpy(_pszUsername, pszUsername);
  67. }
  68. }
  69. __try {
  70. InitializeCriticalSection (&g_csDialogCritSection);
  71. } __except (EXCEPTION_CONTINUE_EXECUTION) {
  72. // Might raise an out of memory exception
  73. // -1 ignores
  74. }
  75. _fDelCs = TRUE;
  76. __try {
  77. InitializeCriticalSection (&g_AppInfoCritSection);
  78. } __except (EXCEPTION_CONTINUE_EXECUTION) {
  79. // Might raise an out of memory exception
  80. // -1 ignores
  81. }
  82. // do we run in OOBE mode? check for oobemode.dat in the curr dir
  83. _fOOBEMode = FALSE; // default
  84. TCHAR szPath[MAX_PATH];
  85. if (GetCurrentDirectory(ARRAYSIZE(szPath), szPath))
  86. {
  87. PathAppend(szPath, TEXT("oobemode.dat"));
  88. HANDLE hFile = CreateFile(szPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
  89. if (INVALID_HANDLE_VALUE != hFile)
  90. {
  91. _fOOBEMode = TRUE;
  92. CloseHandle(hFile);
  93. }
  94. }
  95. OpenAppInf(NULL);
  96. // do we run in legacy mode? (collect-only)
  97. UINT uiVer = GetVersion();
  98. _fLegacyMode = (uiVer >= 0x80000000 || LOBYTE(LOWORD(uiVer)) < 5);
  99. _fWin9X = (uiVer >= 0x80000000);
  100. _fWinNT4 = (uiVer < 0x80000000 && LOBYTE(LOWORD(uiVer)) == 4);
  101. fWinXP = ((uiVer < 0x80000000) && (LOBYTE(LOWORD(uiVer)) == 5) && (HIBYTE(LOWORD(uiVer)) >= 1));
  102. #ifndef PRERELEASE
  103. // in release mode, run legacy on for Win2k
  104. if (HIBYTE(LOWORD(uiVer)) < 1)
  105. {
  106. _fLegacyMode = TRUE;
  107. }
  108. #endif
  109. // do we run with old-style wizard?
  110. _fOldStyle = (uiVer >= 0x80000000 || LOBYTE(LOWORD(uiVer)) < 5); // hack, for now win9x is old-style
  111. // Init common controls
  112. INITCOMMONCONTROLSEX icex;
  113. icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  114. if (fWinXP) {
  115. icex.dwICC = ICC_USEREX_CLASSES | ICC_LINK_CLASS;
  116. } else {
  117. icex.dwICC = ICC_USEREX_CLASSES;
  118. }
  119. InitCommonControlsEx(&icex);
  120. // Init the imagelist
  121. SHFILEINFO sfi = {0};
  122. _hil = (HIMAGELIST)SHGetFileInfo(TEXT(".txt"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi),
  123. SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES);
  124. //
  125. //Create the Wizard pages
  126. //
  127. hr = _CreateWizardPages();
  128. if (SUCCEEDED(hr))
  129. {
  130. //Create the property sheet
  131. _psh.hInstance = _hInstance;
  132. _psh.hwndParent = NULL;
  133. _psh.phpage = _rghpsp;
  134. if (!_fOldStyle)
  135. {
  136. _psh.dwSize = sizeof(_psh);
  137. _psh.dwFlags = PSH_WIZARD97|PSH_WATERMARK|PSH_HEADER;
  138. _psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
  139. _psh.pszbmHeader = MAKEINTRESOURCE(IDB_BANNER);
  140. }
  141. else
  142. {
  143. _psh.dwSize = PROPSHEETHEADER_V1_SIZE;
  144. _psh.dwFlags = PSH_WIZARD;
  145. }
  146. _psh.nStartPage = 0;
  147. _psh.nPages = NUMPAGES;
  148. //Set up the font for the titles on the intro and ending pages
  149. NONCLIENTMETRICS ncm = {0};
  150. ncm.cbSize = sizeof(ncm);
  151. SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  152. //Create the intro/end title font
  153. LOGFONT TitleLogFont = ncm.lfMessageFont;
  154. // ISSUE: we don't want to do this, this can break us on non-English builds.
  155. TitleLogFont.lfWeight = FW_BOLD;
  156. lstrcpy(TitleLogFont.lfFaceName, TEXT("MS Shell Dlg"));
  157. HDC hdc = GetDC(NULL); //gets the screen DC
  158. TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * 12 / 72;
  159. _hTitleFont = CreateFontIndirect(&TitleLogFont);
  160. CHAR szFontSize[MAX_LOADSTRING];
  161. DWORD dwFontSize = 8;
  162. if (LoadStringA(g_hInstance, IDS_WIN9X_HEADER_FONTSIZE, szFontSize, ARRAYSIZE(szFontSize))) {
  163. dwFontSize = strtoul(szFontSize, NULL, 10);
  164. }
  165. TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * dwFontSize / 72;
  166. lstrcpy(TitleLogFont.lfFaceName, TEXT("MS Shell Dlg"));
  167. _h95HeaderFont = CreateFontIndirect(&TitleLogFont);
  168. ReleaseDC(NULL, hdc);
  169. g_hInstance = _hInstance; // HACK: allows message callback to get an hinstance to load strings
  170. }
  171. return hr;
  172. }
  173. HRESULT MigrationWizard::Execute()
  174. {
  175. //Display the wizard
  176. PropertySheet(&_psh);
  177. return S_OK;
  178. }
  179. #define WIZDLG(name, dlgproc) \
  180. psp.dwFlags = _fOldStyle ? PSP_DEFAULT : PSP_DEFAULT|PSP_USEHEADERTITLE;\
  181. psp.pszHeaderTitle = _fOldStyle ? NULL : MAKEINTRESOURCE(IDS_##name##TITLE);\
  182. psp.pszHeaderSubTitle = NULL;\
  183. psp.pszTemplate = MAKEINTRESOURCE(IDD_##name##);\
  184. psp.pfnDlgProc = ##dlgproc##;\
  185. _rghpsp[uiCounter++] = CreatePropertySheetPage(&psp)
  186. #define WIZDLG_TITLE(name, dlgproc) \
  187. psp.dwFlags = _fOldStyle ? PSP_DEFAULT : PSP_DEFAULT|PSP_HIDEHEADER;\
  188. psp.pszHeaderTitle = NULL;\
  189. psp.pszHeaderSubTitle = NULL;\
  190. psp.pszTemplate = MAKEINTRESOURCE(IDD_##name##);\
  191. psp.pfnDlgProc = ##dlgproc##;\
  192. _rghpsp[uiCounter++] = CreatePropertySheetPage(&psp)
  193. HRESULT MigrationWizard::_CreateWizardPages()
  194. {
  195. UINT uiCounter = 0;
  196. PROPSHEETPAGE psp = {0}; //defines the property sheet page
  197. psp.dwSize = sizeof(psp);
  198. psp.hInstance = _hInstance;
  199. psp.lParam = (LPARAM)this;
  200. //Opening page
  201. if (_fOOBEMode)
  202. {
  203. WIZDLG_TITLE(INTROOOBE, _IntroOOBEDlgProc);
  204. }
  205. else if (!_fLegacyMode)
  206. {
  207. WIZDLG_TITLE(INTRO, _IntroDlgProc);
  208. }
  209. else
  210. {
  211. WIZDLG_TITLE(INTROLEGACY, _IntroLegacyDlgProc);
  212. }
  213. // Interior pages
  214. WIZDLG(GETSTARTED, _GetStartedDlgProc);
  215. WIZDLG(ASKCD, _AskCDDlgProc);
  216. WIZDLG(DISKPROGRESS, _DiskProgressDlgProc);
  217. WIZDLG(DISKINSTRUCTIONS, _InstructionsDlgProc);
  218. WIZDLG(CDINSTRUCTIONS, _CDInstructionsDlgProc);
  219. WIZDLG(PICKAPPLYSTORE, _PickApplyStoreDlgProc);
  220. WIZDLG(APPLYPROGRESS, _ApplyProgressDlgProc);
  221. WIZDLG(WAIT, _StartEngineDlgProc);
  222. WIZDLG(PICKMETHOD, _PickMethodDlgProc);
  223. WIZDLG(CUSTOMIZE, _CustomizeDlgProc);
  224. WIZDLG(PICKCOLLECTSTORE, _PickCollectStoreDlgProc);
  225. WIZDLG(COLLECTPROGRESS, _CollectProgressDlgProc);
  226. WIZDLG(DIRECTCABLE, _DirectCableDlgProc);
  227. WIZDLG(FAILCLEANUP, _CleanUpDlgProc);
  228. WIZDLG(APPINSTALL, _AppInstallDlgProc);
  229. //Final pages
  230. WIZDLG_TITLE(ENDAPPLY, _EndApplyDlgProc);
  231. WIZDLG_TITLE(ENDAPPLYFAIL, _EndFailDlgProc);
  232. WIZDLG_TITLE(ENDCOLLECT, _EndCollectDlgProc);
  233. WIZDLG_TITLE(ENDCOLLECTNET, _EndCollectNetDlgProc);
  234. WIZDLG_TITLE(ENDCOLLECTFAIL, _EndFailDlgProc);
  235. WIZDLG_TITLE(ENDOOBE, _EndOOBEDlgProc);
  236. return S_OK;
  237. }
  238. // this lets us know if the user cancelled
  239. void MigrationWizard::ResetLastResponse()
  240. {
  241. g_fLastResponse = TRUE;
  242. }
  243. BOOL MigrationWizard::GetLastResponse()
  244. {
  245. return g_fLastResponse;
  246. }
  247. INT_PTR CALLBACK _WaitDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  248. {
  249. return 0;
  250. }
  251. INT_PTR CALLBACK _DisplayPasswordDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  252. {
  253. static PPASSWORD_DATA passwordData = NULL;
  254. DWORD waitResult;
  255. switch (uMsg)
  256. {
  257. case WM_INITDIALOG :
  258. {
  259. passwordData = (PPASSWORD_DATA) lParam;
  260. if (passwordData) {
  261. if (passwordData->Key) {
  262. SendMessageA (GetDlgItem(hwndDlg, IDC_DISPLAY_PASSWORD), WM_SETTEXT, 0, (LPARAM)passwordData->Key);
  263. }
  264. }
  265. SetTimer (hwndDlg, NULL, 100, NULL);
  266. }
  267. return TRUE;
  268. case WM_COMMAND:
  269. switch (LOWORD(wParam))
  270. {
  271. case IDCANCEL:
  272. EndDialog(hwndDlg, FALSE);
  273. return TRUE;
  274. }
  275. break;
  276. case WM_TIMER:
  277. if (passwordData) {
  278. waitResult = WaitForSingleObject (passwordData->Event, 0);
  279. if (waitResult != WAIT_TIMEOUT) {
  280. EndDialog(hwndDlg, FALSE);
  281. return TRUE;
  282. }
  283. }
  284. }
  285. return 0;
  286. }
  287. INT_PTR CALLBACK _GatherPasswordDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  288. {
  289. static PPASSWORD_DATA passwordData = NULL;
  290. DWORD waitResult;
  291. switch (uMsg)
  292. {
  293. case WM_INITDIALOG :
  294. {
  295. passwordData = (PPASSWORD_DATA) lParam;
  296. if (passwordData) {
  297. if (passwordData->Key) {
  298. SendMessageA (GetDlgItem(hwndDlg, IDC_GATHER_PASSWORD), WM_SETTEXT, 0, (LPARAM)passwordData->Key);
  299. }
  300. Edit_LimitText(GetDlgItem(hwndDlg, IDC_GATHER_PASSWORD), passwordData->KeySize - 1);
  301. }
  302. }
  303. return TRUE;
  304. case WM_COMMAND:
  305. switch (LOWORD(wParam))
  306. {
  307. case IDOK:
  308. if (passwordData && passwordData->Key) {
  309. SendMessageA (GetDlgItem(hwndDlg, IDC_GATHER_PASSWORD), WM_GETTEXT, passwordData->KeySize, (LPARAM)passwordData->Key);
  310. EndDialog(hwndDlg, TRUE);
  311. } else {
  312. EndDialog(hwndDlg, FALSE);
  313. }
  314. return TRUE;
  315. case IDCANCEL:
  316. EndDialog(hwndDlg, FALSE);
  317. return TRUE;
  318. }
  319. break;
  320. }
  321. return 0;
  322. }
  323. INT_PTR CALLBACK _ChooseDestDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  324. {
  325. switch (uMsg)
  326. {
  327. case WM_NOTIFY :
  328. switch (((LPNMHDR)lParam)->code)
  329. {
  330. case NM_DBLCLK:
  331. // On this dialog, this message can only come from the listview.
  332. // If there is something selected, that means the user doubleclicked on an item
  333. // On a doubleclick we will trigger the OK button
  334. if (ListView_GetSelectedCount(GetDlgItem(hwndDlg, IDC_DESTPICKER_LIST)) > 0)
  335. {
  336. SendMessage (GetDlgItem(hwndDlg, IDOK), BM_CLICK, 0, 0);
  337. }
  338. break;
  339. case LVN_ITEMCHANGED:
  340. if (ListView_GetSelectedCount(GetDlgItem(hwndDlg, IDC_DESTPICKER_LIST)) > 0)
  341. {
  342. Button_Enable(GetDlgItem(hwndDlg, IDOK), TRUE);
  343. }
  344. else
  345. {
  346. Button_Enable(GetDlgItem(hwndDlg, IDOK), FALSE);
  347. }
  348. break;
  349. }
  350. break;
  351. case WM_INITDIALOG :
  352. {
  353. HWND hwndList = GetDlgItem(hwndDlg, IDC_DESTPICKER_LIST);
  354. ListView_DeleteAllItems(hwndList);
  355. LVCOLUMN lvcolumn;
  356. lvcolumn.mask = LVCF_WIDTH;
  357. lvcolumn.cx = 250; // BUGBUG: should read width from box
  358. ListView_InsertColumn(hwndList, 0, &lvcolumn);
  359. LVITEM lvitem = {0};
  360. lvitem.mask = LVIF_TEXT;
  361. Button_Enable(GetDlgItem(hwndDlg, IDOK), FALSE);
  362. LPTSTR pszPtr = g_szMultiDests;
  363. BOOL fDone = FALSE;
  364. while (*pszPtr != NULL)
  365. {
  366. lvitem.iItem = lvitem.iItem = ListView_GetItemCount(hwndList);
  367. lvitem.pszText = pszPtr;
  368. ListView_InsertItem(hwndList, &lvitem);
  369. pszPtr += (lstrlen(pszPtr) + 1);
  370. }
  371. }
  372. return TRUE;
  373. break;
  374. case WM_COMMAND:
  375. switch (LOWORD(wParam))
  376. {
  377. case IDOK:
  378. {
  379. UINT uiSelected = ListView_GetSelectionMark(GetDlgItem(hwndDlg, IDC_DESTPICKER_LIST));
  380. ListView_GetItemText(GetDlgItem(hwndDlg, IDC_DESTPICKER_LIST), uiSelected, 0, g_szMultiDests, ARRAYSIZE(g_szMultiDests));
  381. g_szMultiDests[lstrlen(g_szMultiDests) + 1] = 0; // double-null terminate the multi-sz
  382. EndDialog(hwndDlg, TRUE);
  383. return TRUE;
  384. }
  385. break;
  386. case IDCANCEL:
  387. EndDialog(hwndDlg, FALSE);
  388. return TRUE;
  389. break;
  390. }
  391. break;
  392. }
  393. return 0;
  394. }
  395. BOOL
  396. _ExclusiveMessageBoxVaArgs (
  397. IN PTSTR pszTitle,
  398. IN BOOL RetryCancel,
  399. IN DWORD dwResourceId,
  400. ...
  401. )
  402. {
  403. TCHAR szErrMsg[MAX_LOADSTRING];
  404. TCHAR szErrStr[MAX_LOADSTRING];
  405. va_list args;
  406. LoadString(g_hInstance, dwResourceId, szErrMsg, ARRAYSIZE(szErrMsg));
  407. va_start (args, dwResourceId);
  408. FormatMessage (FORMAT_MESSAGE_FROM_STRING, szErrMsg, 0, 0, (LPTSTR)szErrStr, ARRAYSIZE (szErrStr), &args);
  409. va_end (args);
  410. if (RetryCancel) {
  411. return (IDRETRY == _ExclusiveMessageBox (g_hwndCurrent,szErrStr,pszTitle,MB_RETRYCANCEL));
  412. } else {
  413. return (IDOK == _ExclusiveMessageBox (g_hwndCurrent,szErrStr,pszTitle,MB_OKCANCEL));
  414. }
  415. }
  416. PCTSTR
  417. pGenerateNewNode (
  418. IN PCTSTR OldNode
  419. )
  420. {
  421. PTSTR newNode;
  422. PTSTR newNodePtr;
  423. PCTSTR result = NULL;
  424. newNode = (PTSTR)LocalAlloc (LPTR, (_tcslen (TEXT ("%CSIDL_PERSONAL%\\")) + _tcslen (OldNode) + 1) * sizeof (TCHAR));
  425. if (newNode) {
  426. _tcscpy (newNode, TEXT("%CSIDL_PERSONAL%\\"));
  427. _tcscat (newNode, OldNode);
  428. newNodePtr = _tcschr (newNode, TEXT(':'));
  429. while (newNodePtr) {
  430. *newNodePtr = TEXT('_');
  431. newNodePtr = _tcschr (newNode, TEXT(':'));
  432. }
  433. result = IsmExpandEnvironmentString (PLATFORM_DESTINATION, S_SYSENVVAR_GROUP, newNode, NULL);
  434. LocalFree ((PVOID)newNode);
  435. }
  436. return result;
  437. }
  438. BOOL
  439. pForceRestoreObject (
  440. IN MIG_OBJECTSTRINGHANDLE EncodedFileName,
  441. IN OUT POBJLIST ObjList
  442. )
  443. {
  444. MIG_CONTENT objectContent;
  445. PCTSTR node = NULL;
  446. PCTSTR leaf = NULL;
  447. PCTSTR newNode = NULL;
  448. MIG_OBJECTSTRINGHANDLE newFileName;
  449. BOOL result = FALSE;
  450. if (IsmAcquireObject (MIG_FILE_TYPE | PLATFORM_SOURCE, EncodedFileName, &objectContent)) {
  451. // let's build the new name for this file
  452. if (IsmCreateObjectStringsFromHandle (EncodedFileName, &node, &leaf)) {
  453. if (node && leaf) {
  454. newNode = pGenerateNewNode (node);
  455. if (newNode) {
  456. newFileName = IsmCreateObjectHandle (newNode, leaf);
  457. if (newFileName) {
  458. result = IsmReplacePhysicalObject (
  459. MIG_FILE_TYPE | PLATFORM_DESTINATION,
  460. newFileName,
  461. &objectContent
  462. );
  463. if (result && ObjList) {
  464. ObjList->AlternateName = (PTSTR)LocalAlloc (LPTR, (_tcslen (newFileName) + 1) * sizeof (TCHAR));
  465. if (ObjList->AlternateName) {
  466. _tcscpy (ObjList->AlternateName, newFileName);
  467. }
  468. }
  469. IsmDestroyObjectHandle (newFileName);
  470. }
  471. IsmReleaseMemory (newNode);
  472. }
  473. }
  474. if (node) {
  475. IsmDestroyObjectString (node);
  476. node = NULL;
  477. }
  478. if (leaf) {
  479. IsmDestroyObjectString (leaf);
  480. leaf = NULL;
  481. }
  482. }
  483. IsmReleaseObject (&objectContent);
  484. }
  485. return result;
  486. }
  487. ULONG_PTR MessageCallback (UINT uiMsg, ULONG_PTR pArg)
  488. {
  489. PRMEDIA_EXTRADATA extraData;
  490. PTRANSCOPY_ERROR transCopyError;
  491. PERRUSER_EXTRADATA errExtraData;
  492. PROLLBACK_USER_ERROR rollbackError;
  493. PPASSWORD_DATA passwordData;
  494. PMIG_APPINFO appInfo;
  495. PQUESTION_DATA questionData;
  496. int msgBoxReturn;
  497. TCHAR szTitle[MAX_LOADSTRING];
  498. LoadString(g_hInstance, IDS_MIGWIZTITLE, szTitle, ARRAYSIZE(szTitle));
  499. TCHAR szErrMsg[MAX_LOADSTRING];
  500. TCHAR szErrStr[MAX_LOADSTRING];
  501. POBJLIST wrnObj = NULL;
  502. PCTSTR objectType = NULL;
  503. PCTSTR objectName = NULL;
  504. static DWORD dwTypeID = 0;
  505. switch (uiMsg)
  506. {
  507. case MODULEMESSAGE_ASKQUESTION:
  508. questionData = (PQUESTION_DATA) pArg;
  509. if (questionData) {
  510. if (MessageBox (g_hwndCurrent, questionData->Question, szTitle, questionData->MessageStyle) == questionData->WantedResult) {
  511. return APPRESPONSE_SUCCESS;
  512. } else {
  513. return APPRESPONSE_FAIL;
  514. }
  515. }
  516. return APPRESPONSE_SUCCESS;
  517. case ISMMESSAGE_APP_INFO:
  518. case ISMMESSAGE_APP_INFO_NOW:
  519. appInfo = (PMIG_APPINFO) pArg;
  520. if (appInfo) {
  521. EnterCriticalSection(&g_AppInfoCritSection);
  522. g_AppInfoPhase = appInfo->Phase;
  523. g_AppInfoSubPhase = appInfo->SubPhase;
  524. g_AppInfoObjectTypeId = appInfo->ObjectTypeId;
  525. if (appInfo->ObjectName) {
  526. _tcsncpy (g_AppInfoObjectName, appInfo->ObjectName, 4096);
  527. } else {
  528. g_AppInfoObjectName [0] = 0;
  529. }
  530. if (appInfo->Text) {
  531. _tcsncpy (g_AppInfoText, appInfo->Text, 4096);
  532. } else {
  533. g_AppInfoText [0] = 0;
  534. }
  535. LeaveCriticalSection(&g_AppInfoCritSection);
  536. if (uiMsg == ISMMESSAGE_APP_INFO_NOW) {
  537. SendMessage (g_hwndCurrent, WM_USER_STATUS, 0, 0);
  538. }
  539. }
  540. return APPRESPONSE_SUCCESS;
  541. case TRANSPORTMESSAGE_OLD_STORAGE:
  542. LoadString(g_hInstance, IDS_ENGERR_IMAGE_OLDFORMAT, szErrMsg, ARRAYSIZE(szErrMsg));
  543. _ExclusiveMessageBox (g_hwndCurrent, szErrMsg, szTitle, MB_OK);
  544. return 0;
  545. case TRANSPORTMESSAGE_IMAGE_EXISTS:
  546. LoadString(g_hInstance, IDS_ENGERR_IMAGE_EXISTS, szErrMsg, ARRAYSIZE(szErrMsg));
  547. g_fLastResponse = (IDYES == _ExclusiveMessageBox (g_hwndCurrent, szErrMsg, szTitle, MB_YESNO));
  548. return g_fLastResponse;
  549. case TRANSPORTMESSAGE_SIZE_SAVED:
  550. return APPRESPONSE_SUCCESS;
  551. case TRANSPORTMESSAGE_RMEDIA_LOAD:
  552. case TRANSPORTMESSAGE_RMEDIA_SAVE:
  553. extraData = (PRMEDIA_EXTRADATA) pArg;
  554. if (!extraData) {
  555. LoadString(g_hInstance, IDS_ENGERR_NEXT_MEDIA, szErrMsg, ARRAYSIZE(szErrMsg));
  556. g_fLastResponse = (IDOK == _ExclusiveMessageBox (g_hwndCurrent,szErrMsg,szTitle,MB_OKCANCEL));
  557. } else {
  558. switch (extraData->LastError)
  559. {
  560. case RMEDIA_ERR_NOERROR:
  561. if (uiMsg == TRANSPORTMESSAGE_RMEDIA_LOAD) {
  562. g_fLastResponse = _ExclusiveMessageBoxVaArgs (
  563. szTitle,
  564. FALSE,
  565. IDS_ENGERR_INSERT_DEST_MEDIA_NUMBER,
  566. extraData->MediaNumber
  567. );
  568. } else {
  569. if (extraData->MediaNumber == 1) {
  570. DOUBLE sizeMB = (DOUBLE) extraData->TotalImageSize / (1024 * 1024);
  571. UINT intMB = (UINT) sizeMB;
  572. UINT decMB = (UINT) ((sizeMB - intMB) * 100);
  573. UINT sizeF = (UINT) (sizeMB / 1.44);
  574. UINT sizeZ = (UINT) (sizeMB / 100);
  575. if (sizeF < 1) {
  576. LoadString(g_hInstance, IDS_ENGERR_INSERT_FIRST_MEDIA1, szErrMsg, ARRAYSIZE(szErrMsg));
  577. wsprintf (szErrStr, szErrMsg, intMB, decMB);
  578. } else if (sizeZ < 1) {
  579. LoadString(g_hInstance, IDS_ENGERR_INSERT_FIRST_MEDIA2, szErrMsg, ARRAYSIZE(szErrMsg));
  580. wsprintf (szErrStr, szErrMsg, intMB, decMB, 1 + sizeF);
  581. } else {
  582. LoadString(g_hInstance, IDS_ENGERR_INSERT_FIRST_MEDIA3, szErrMsg, ARRAYSIZE(szErrMsg));
  583. wsprintf (szErrStr, szErrMsg, intMB, decMB, 1 + sizeF, 1 + sizeZ);
  584. }
  585. g_fLastResponse = (IDOK == _ExclusiveMessageBox (g_hwndCurrent,szErrStr,szTitle,MB_OKCANCEL));
  586. } else {
  587. UINT iDisks;
  588. ULONGLONG ullBytesPerDisk;
  589. ullBytesPerDisk = extraData->TotalImageWritten / (extraData->MediaNumber - 1);
  590. if (ullBytesPerDisk) {
  591. iDisks = (UINT)(extraData->TotalImageSize / ullBytesPerDisk) + 1;
  592. g_fLastResponse = _ExclusiveMessageBoxVaArgs (
  593. szTitle,
  594. FALSE,
  595. IDS_ENGERR_INSERT_MEDIA_NUMBER,
  596. extraData->MediaNumber,
  597. iDisks
  598. );
  599. } else {
  600. LoadString(g_hInstance, IDS_ENGERR_NEXT_MEDIA, szErrMsg, ARRAYSIZE(szErrMsg));
  601. g_fLastResponse = (IDOK == _ExclusiveMessageBox (g_hwndCurrent,szErrMsg,szTitle,MB_OKCANCEL));
  602. }
  603. }
  604. }
  605. break;
  606. case RMEDIA_ERR_WRONGMEDIA:
  607. g_fLastResponse = _ExclusiveMessageBoxVaArgs (szTitle,
  608. TRUE,
  609. IDS_ENGERR_WRONG_MEDIA,
  610. extraData->MediaNumber);
  611. break;
  612. case RMEDIA_ERR_USEDMEDIA:
  613. g_fLastResponse = _ExclusiveMessageBoxVaArgs (szTitle,
  614. FALSE,
  615. IDS_ENGERR_USED_MEDIA,
  616. extraData->MediaNumber);
  617. break;
  618. case RMEDIA_ERR_DISKFULL:
  619. LoadString(g_hInstance, IDS_ENGERR_FULL, szErrMsg, ARRAYSIZE(szErrMsg));
  620. g_fLastResponse = (IDRETRY == _ExclusiveMessageBox (g_hwndCurrent,szErrMsg,szTitle,MB_RETRYCANCEL));
  621. break;
  622. case RMEDIA_ERR_NOTREADY:
  623. LoadString(g_hInstance, IDS_ENGERR_NOTREADY, szErrMsg, ARRAYSIZE(szErrMsg));
  624. g_fLastResponse = (IDRETRY == _ExclusiveMessageBox (g_hwndCurrent,szErrMsg,szTitle,MB_RETRYCANCEL));
  625. break;
  626. case RMEDIA_ERR_WRITEPROTECT:
  627. LoadString(g_hInstance, IDS_ENGERR_WRITEPROTECT, szErrMsg, ARRAYSIZE(szErrMsg));
  628. g_fLastResponse = (IDRETRY == _ExclusiveMessageBox (g_hwndCurrent,szErrMsg,szTitle,MB_RETRYCANCEL));
  629. break;
  630. case RMEDIA_ERR_CRITICAL:
  631. g_fLastResponse = FALSE;
  632. break;
  633. default:
  634. LoadString(g_hInstance, IDS_ENGERR_TOAST, szErrMsg, ARRAYSIZE(szErrMsg));
  635. g_fLastResponse = (IDRETRY == _ExclusiveMessageBox (g_hwndCurrent,szErrMsg,szTitle,MB_RETRYCANCEL));
  636. }
  637. return g_fLastResponse;
  638. }
  639. case TRANSPORTMESSAGE_READY_TO_CONNECT:
  640. // this message is received only on the new machine
  641. g_fReadFromNetwork = TRUE; // this means go ahead and read from the network immediately
  642. PropSheet_PressButton(GetParent(g_hwndCurrent), PSBTN_NEXT);
  643. return APPRESPONSE_SUCCESS;
  644. case TRANSPORTMESSAGE_MULTIPLE_DESTS:
  645. // this is received only on the old machine
  646. {
  647. if (g_fReceivedMultiDest)
  648. {
  649. return APPRESPONSE_SUCCESS;
  650. }
  651. else
  652. {
  653. g_fReceivedMultiDest = TRUE;
  654. ULONG_PTR uiRetVal = APPRESPONSE_FAIL;
  655. g_fHaveNet = FALSE; // disable network unless user chooses a destination
  656. TCHAR szDestinations[20 * MAX_PATH];
  657. if (IsmGetEnvironmentMultiSz (
  658. PLATFORM_DESTINATION,
  659. NULL,
  660. TRANSPORT_ENVVAR_HOMENET_DESTINATIONS,
  661. szDestinations,
  662. ARRAYSIZE(szDestinations),
  663. NULL
  664. ))
  665. {
  666. memcpy(g_szMultiDests, szDestinations, sizeof(TCHAR) * ARRAYSIZE(szDestinations));
  667. if (_ExclusiveDialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DESTPICKER), g_hwndCurrent, _ChooseDestDlgProc))
  668. {
  669. IsmSetEnvironmentMultiSz (
  670. PLATFORM_DESTINATION,
  671. NULL,
  672. TRANSPORT_ENVVAR_HOMENET_DESTINATIONS,
  673. g_szMultiDests
  674. );
  675. uiRetVal = APPRESPONSE_SUCCESS;
  676. g_fHaveNet = TRUE; // re-enable network
  677. }
  678. else
  679. {
  680. g_fUberCancel = TRUE;
  681. Engine_Cancel();
  682. }
  683. }
  684. return uiRetVal;
  685. }
  686. }
  687. case ISMMESSAGE_EXECUTE_PREPROCESS:
  688. if (!g_migwiz->GetOOBEMode()) {
  689. AppExecute (g_migwiz->GetInstance(), g_hwndCurrent, (PCTSTR) pArg);
  690. }
  691. return APPRESPONSE_SUCCESS;
  692. case ISMMESSAGE_EXECUTE_REFRESH:
  693. if (!g_migwiz->GetOOBEMode() && !g_fUberCancel) {
  694. AppExecute (g_migwiz->GetInstance(), g_hwndCurrent, (PCTSTR) pArg);
  695. }
  696. return APPRESPONSE_SUCCESS;
  697. case ISMMESSAGE_EXECUTE_POSTPROCESS:
  698. if (!g_migwiz->GetOOBEMode()) {
  699. AppExecute (g_migwiz->GetInstance(), g_hwndCurrent, (PCTSTR) pArg);
  700. }
  701. return APPRESPONSE_SUCCESS;
  702. case ISMMESSAGE_EXECUTE_ROLLBACK:
  703. rollbackError = (PROLLBACK_USER_ERROR) pArg;
  704. if (rollbackError) {
  705. LoadString(g_hInstance, IDS_CANTROLLBACK, szErrMsg, ARRAYSIZE(szErrMsg));
  706. wsprintf (szErrStr, szErrMsg, rollbackError->UserDomain, rollbackError->UserName);
  707. _ExclusiveMessageBox (g_hwndCurrent,szErrStr,szTitle,MB_OK);
  708. }
  709. return APPRESPONSE_SUCCESS;
  710. case TRANSPORTMESSAGE_SRC_COPY_ERROR:
  711. transCopyError = (PTRANSCOPY_ERROR) pArg;
  712. if (transCopyError) {
  713. if (StrCmpI (transCopyError->ObjectType, TEXT("File")) == 0) {
  714. if ((transCopyError->Error == ERROR_SHARING_VIOLATION) ||
  715. (transCopyError->Error == ERROR_LOCK_VIOLATION) ||
  716. (transCopyError->Error == 0x80090020) // found this on a WinME machine, when a file was locked
  717. ) {
  718. LoadString(g_hInstance, IDS_ENGERR_COPYSOURCE, szErrMsg, ARRAYSIZE(szErrMsg));
  719. wsprintf (szErrStr, szErrMsg, transCopyError->ObjectName);
  720. msgBoxReturn = _ExclusiveMessageBox (g_hwndCurrent,szErrStr,szTitle,MB_ABORTRETRYIGNORE | MB_DEFBUTTON2);
  721. if (msgBoxReturn == IDRETRY) {
  722. return APPRESPONSE_SUCCESS;
  723. }
  724. if (msgBoxReturn == IDIGNORE) {
  725. return APPRESPONSE_IGNORE;
  726. }
  727. return APPRESPONSE_FAIL;
  728. }
  729. // we don't really know what was the problem here.
  730. // Let's just continue, at the end we will tell the
  731. // user about this file and he will copy it manually.
  732. return APPRESPONSE_IGNORE;
  733. }
  734. }
  735. return APPRESPONSE_FAIL;
  736. case MODULEMESSAGE_DISPLAYERROR:
  737. errExtraData = (PERRUSER_EXTRADATA) pArg;
  738. if (errExtraData && !g_HTMLErrArea) {
  739. switch (errExtraData->ErrorArea) {
  740. case ERRUSER_AREA_INIT:
  741. g_HTMLErrArea = IDS_ERRORAREA_INIT;
  742. break;
  743. case ERRUSER_AREA_GATHER:
  744. g_HTMLErrArea = IDS_ERRORAREA_GATHER;
  745. break;
  746. case ERRUSER_AREA_SAVE:
  747. g_HTMLErrArea = IDS_ERRORAREA_SAVE;
  748. break;
  749. case ERRUSER_AREA_LOAD:
  750. g_HTMLErrArea = IDS_ERRORAREA_LOAD;
  751. break;
  752. case ERRUSER_AREA_RESTORE:
  753. g_HTMLErrArea = IDS_ERRORAREA_RESTORE;
  754. break;
  755. default:
  756. g_HTMLErrArea = IDS_ERRORAREA_UNKNOWN;
  757. }
  758. switch (errExtraData->Error) {
  759. case ERRUSER_ERROR_NOTRANSPORTPATH:
  760. g_HTMLErrInstr = IDS_ERROR_NOTRANSPORTPATH;
  761. break;
  762. case ERRUSER_ERROR_TRANSPORTPATHBUSY:
  763. case ERRUSER_ERROR_CANTEMPTYDIR:
  764. case ERRUSER_ERROR_ALREADYEXISTS:
  765. case ERRUSER_ERROR_CANTCREATEDIR:
  766. case ERRUSER_ERROR_CANTCREATESTATUS:
  767. case ERRUSER_ERROR_CANTWRITETODESTPATH:
  768. g_HTMLErrInstr = IDS_ERROR_TRANSPORTNOACCESS;
  769. break;
  770. case ERRUSER_ERROR_CANTCREATETEMPDIR:
  771. case ERRUSER_ERROR_CANTCREATECABFILE:
  772. case ERRUSER_ERROR_CANTSAVEINTERNALDATA:
  773. g_HTMLErrInstr = IDS_ERROR_TRANSPORTINTERNALERROR;
  774. break;
  775. case ERRUSER_ERROR_TRANSPORTINVALIDIMAGE:
  776. case ERRUSER_ERROR_CANTOPENSTATUS:
  777. case ERRUSER_ERROR_CANTREADIMAGE:
  778. g_HTMLErrInstr = IDS_ERROR_TRANSPORTNOVALIDSOURCE;
  779. break;
  780. case ERRUSER_ERROR_CANTFINDDESTINATION:
  781. case ERRUSER_ERROR_CANTSENDTODEST:
  782. g_HTMLErrInstr = IDS_ERROR_HOMENETINVALIDDEST;
  783. break;
  784. case ERRUSER_ERROR_CANTFINDSOURCE:
  785. case ERRUSER_ERROR_CANTRECEIVEFROMSOURCE:
  786. case ERRUSER_ERROR_INVALIDDATARECEIVED:
  787. g_HTMLErrInstr = IDS_ERROR_HOMENETINVALIDSRC;
  788. break;
  789. case ERRUSER_ERROR_NOENCRYPTION:
  790. g_HTMLErrInstr = IDS_ERROR_HOMENETINVALIDENC;
  791. break;
  792. case ERRUSER_ERROR_CANTUNPACKIMAGE:
  793. g_HTMLErrInstr = IDS_ERROR_TRANSPORTINTERNALERROR;
  794. break;
  795. case ERRUSER_ERROR_CANTSAVEOBJECT:
  796. case ERRUSER_ERROR_CANTRESTOREOBJECT:
  797. if (errExtraData->ErrorArea == ERRUSER_AREA_SAVE) {
  798. g_HTMLErrInstr = IDS_ERROR_CANTSAVEOBJECT;
  799. } else {
  800. g_HTMLErrInstr = IDS_ERROR_CANTRESTOREOBJECT;
  801. }
  802. if (errExtraData->ObjectTypeId && errExtraData->ObjectName) {
  803. objectType = IsmGetObjectTypeName (errExtraData->ObjectTypeId);
  804. if (objectType) {
  805. objectName = IsmGetNativeObjectName (errExtraData->ObjectTypeId, errExtraData->ObjectName);
  806. if (objectName) {
  807. if (StrCmpI (objectType, TEXT("File")) == 0) {
  808. wrnObj = _AllocateObjectList (objectName);
  809. wrnObj->Next = g_HTMLWrnFile;
  810. g_HTMLWrnFile = wrnObj;
  811. } else if (StrCmpI (objectType, TEXT("RasConnection")) == 0) {
  812. wrnObj = _AllocateObjectList (objectName);
  813. wrnObj->Next = g_HTMLWrnRas;
  814. g_HTMLWrnRas = wrnObj;
  815. } else if (StrCmpI (objectType, TEXT("MappedDrives")) == 0) {
  816. wrnObj = _AllocateObjectList (objectName);
  817. wrnObj->Next = g_HTMLWrnNet;
  818. g_HTMLWrnNet = wrnObj;
  819. } else if (StrCmpI (objectType, TEXT("Printers")) == 0) {
  820. wrnObj = _AllocateObjectList (objectName);
  821. wrnObj->Next = g_HTMLWrnPrn;
  822. g_HTMLWrnPrn = wrnObj;
  823. }
  824. IsmReleaseMemory (objectName);
  825. objectName = NULL;
  826. }
  827. objectType = NULL;
  828. }
  829. }
  830. break;
  831. case ERRUSER_WARNING_OUTLOOKRULES:
  832. g_HTMLErrInstr = IDS_ERROR_CANTRESTOREOBJECT;
  833. LoadString(g_hInstance, IDS_WARNING_OUTLOOKRULES, szErrMsg, ARRAYSIZE(szErrMsg));
  834. wrnObj = _AllocateObjectList (szErrMsg);
  835. wrnObj->Next = g_HTMLWrnGeneral;
  836. g_HTMLWrnGeneral = wrnObj;
  837. break;
  838. case ERRUSER_WARNING_OERULES:
  839. g_HTMLErrInstr = IDS_ERROR_CANTRESTOREOBJECT;
  840. LoadString(g_hInstance, IDS_WARNING_OERULES, szErrMsg, ARRAYSIZE(szErrMsg));
  841. wrnObj = _AllocateObjectList (szErrMsg);
  842. wrnObj->Next = g_HTMLWrnGeneral;
  843. g_HTMLWrnGeneral = wrnObj;
  844. break;
  845. case ERRUSER_ERROR_DISKSPACE:
  846. g_HTMLErrInstr = IDS_ERROR_DISKSPACE;
  847. break;
  848. }
  849. }
  850. return APPRESPONSE_SUCCESS;
  851. case MODULEMESSAGE_DISPLAYWARNING:
  852. errExtraData = (PERRUSER_EXTRADATA) pArg;
  853. if (errExtraData) {
  854. switch (errExtraData->Error) {
  855. case ERRUSER_ERROR_CANTSAVEOBJECT:
  856. case ERRUSER_ERROR_CANTRESTOREOBJECT:
  857. if (errExtraData->ObjectTypeId && errExtraData->ObjectName) {
  858. objectType = IsmGetObjectTypeName (errExtraData->ObjectTypeId);
  859. if (objectType) {
  860. objectName = IsmGetNativeObjectName (errExtraData->ObjectTypeId, errExtraData->ObjectName);
  861. if (objectName) {
  862. if (StrCmpI (objectType, TEXT("File")) == 0) {
  863. // If we are restoring this file, we are going to try
  864. // to write it to a default location where the user
  865. // can find it later
  866. if (errExtraData->Error == ERRUSER_ERROR_CANTRESTOREOBJECT) {
  867. wrnObj = _AllocateObjectList (objectName);
  868. if (pForceRestoreObject (errExtraData->ObjectName, wrnObj)) {
  869. wrnObj->Next = g_HTMLWrnAltFile;
  870. g_HTMLWrnAltFile = wrnObj;
  871. } else {
  872. wrnObj->Next = g_HTMLWrnFile;
  873. g_HTMLWrnFile = wrnObj;
  874. }
  875. } else {
  876. wrnObj = _AllocateObjectList (objectName);
  877. wrnObj->Next = g_HTMLWrnFile;
  878. g_HTMLWrnFile = wrnObj;
  879. }
  880. } else if (StrCmpI (objectType, TEXT("RasConnection")) == 0) {
  881. wrnObj = _AllocateObjectList (objectName);
  882. wrnObj->Next = g_HTMLWrnRas;
  883. g_HTMLWrnRas = wrnObj;
  884. } else if (StrCmpI (objectType, TEXT("MappedDrives")) == 0) {
  885. wrnObj = _AllocateObjectList (objectName);
  886. wrnObj->Next = g_HTMLWrnNet;
  887. g_HTMLWrnNet = wrnObj;
  888. } else if (StrCmpI (objectType, TEXT("Printers")) == 0) {
  889. wrnObj = _AllocateObjectList (objectName);
  890. wrnObj->Next = g_HTMLWrnPrn;
  891. g_HTMLWrnPrn = wrnObj;
  892. }
  893. IsmReleaseMemory (objectName);
  894. objectName = NULL;
  895. }
  896. objectType = NULL;
  897. }
  898. }
  899. break;
  900. }
  901. }
  902. return APPRESPONSE_SUCCESS;
  903. case TRANSPORTMESSAGE_NET_DISPLAY_PASSWORD:
  904. passwordData = (PPASSWORD_DATA) pArg;
  905. if (passwordData) {
  906. DialogBoxParam (
  907. g_hInstance,
  908. MAKEINTRESOURCE(IDD_DISPLAY_PASSWORD),
  909. g_hwndCurrent,
  910. _DisplayPasswordDlgProc,
  911. (LPARAM)passwordData
  912. );
  913. }
  914. return APPRESPONSE_SUCCESS;
  915. case TRANSPORTMESSAGE_NET_GATHER_PASSWORD:
  916. passwordData = (PPASSWORD_DATA) pArg;
  917. if (passwordData) {
  918. if (DialogBoxParam (
  919. g_hInstance,
  920. MAKEINTRESOURCE(IDD_GATHER_PASSWORD),
  921. g_hwndCurrent,
  922. _GatherPasswordDlgProc,
  923. (LPARAM)passwordData
  924. )) {
  925. return APPRESPONSE_SUCCESS;
  926. }
  927. }
  928. return APPRESPONSE_FAIL;
  929. }
  930. return FALSE;
  931. }
  932. HRESULT MigrationWizard::_InitEngine(BOOL fSource, BOOL* pfNetworkDetected)
  933. {
  934. HRESULT hr;
  935. TCHAR szAppPath[MAX_PATH] = TEXT("");
  936. TCHAR* pszAppPathOffset;
  937. GetModuleFileName (NULL, szAppPath, ARRAYSIZE(szAppPath));
  938. pszAppPathOffset = _tcsrchr (szAppPath, TEXT('\\'));
  939. if (pszAppPathOffset) {
  940. pszAppPathOffset ++;
  941. } else {
  942. pszAppPathOffset = szAppPath;
  943. }
  944. _tcsncpy (pszAppPathOffset, TEXT("migism.inf"), ARRAYSIZE(szAppPath) - (pszAppPathOffset - szAppPath));
  945. hr = Engine_Initialize(szAppPath, fSource, TRUE, _pszUsername, MessageCallback, pfNetworkDetected);
  946. if (SUCCEEDED(hr))
  947. {
  948. _fInit = TRUE;
  949. _tcsncpy (pszAppPathOffset, TEXT("migwiz.inf"), ARRAYSIZE(szAppPath) - (pszAppPathOffset - szAppPath));
  950. hr = Engine_AppendScript(fSource, szAppPath);
  951. if (SUCCEEDED(hr))
  952. {
  953. _tcsncpy (pszAppPathOffset, TEXT("usmtdef.inf"), ARRAYSIZE(szAppPath) - (pszAppPathOffset - szAppPath));
  954. hr = Engine_AppendScript(fSource, szAppPath);
  955. }
  956. if (SUCCEEDED(hr))
  957. {
  958. _tcsncpy (pszAppPathOffset, TEXT("migapp.inf"), ARRAYSIZE(szAppPath) - (pszAppPathOffset - szAppPath));
  959. hr = Engine_AppendScript(fSource, szAppPath);
  960. }
  961. if (SUCCEEDED(hr))
  962. {
  963. _tcsncpy (pszAppPathOffset, TEXT("migsys.inf"), ARRAYSIZE(szAppPath) - (pszAppPathOffset - szAppPath));
  964. hr = Engine_AppendScript(fSource, szAppPath);
  965. }
  966. if (SUCCEEDED(hr))
  967. {
  968. _tcsncpy (pszAppPathOffset, TEXT("miguser.inf"), ARRAYSIZE(szAppPath) - (pszAppPathOffset - szAppPath));
  969. hr = Engine_AppendScript(fSource, szAppPath);
  970. }
  971. if (SUCCEEDED(hr))
  972. {
  973. _tcsncpy (pszAppPathOffset, TEXT("sysfiles.inf"), ARRAYSIZE(szAppPath) - (pszAppPathOffset - szAppPath));
  974. hr = Engine_AppendScript(fSource, szAppPath);
  975. }
  976. if (fSource)
  977. {
  978. if (SUCCEEDED(hr))
  979. {
  980. hr = Engine_Parse();
  981. }
  982. }
  983. }
  984. return hr;
  985. }
  986. HRESULT MigrationWizard::SelectComponentSet(UINT uSelectionGroup)
  987. {
  988. if (_fOOBEMode)
  989. {
  990. Engine_SelectComponentSet(MIGINF_SELECT_OOBE);
  991. }
  992. else
  993. {
  994. Engine_SelectComponentSet(uSelectionGroup);
  995. }
  996. return S_OK;
  997. }