|
|
1.1 root 1: /*
2: Legal Notice: Some portions of the source code contained in this file were
3: derived from the source code of Encryption for the Masses 2.02a, which is
4: Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
5: Agreement for Encryption for the Masses'. Modifications and additions to
1.1.1.9 root 6: the original source code (contained in this file) and all other portions
1.1.1.10 root 7: of this file are Copyright (c) 2003-2010 TrueCrypt Developers Association
8: and are governed by the TrueCrypt License 3.0 the full text of which is
1.1.1.9 root 9: contained in the file License.txt included in TrueCrypt binary and source
10: code distribution packages. */
1.1 root 11:
12: #include "Tcdefs.h"
1.1.1.10 root 13: #include <Shlobj.h>
14: #include <io.h>
1.1.1.11! root 15: #include <stdio.h>
! 16: #include <time.h>
1.1 root 17: #include "SelfExtract.h"
18: #include "Wizard.h"
19: #include "Dlgcode.h"
20: #include "Language.h"
21: #include "Common/Resource.h"
22: #include "Resource.h"
1.1.1.8 root 23: #include "Setup.h"
1.1 root 24:
1.1.1.10 root 25: using namespace std;
26:
1.1 root 27: enum wizard_pages
28: {
29: INTRO_PAGE,
30: WIZARD_MODE_PAGE,
31: INSTALL_OPTIONS_PAGE,
32: INSTALL_PROGRESS_PAGE,
33: EXTRACTION_OPTIONS_PAGE,
1.1.1.11! root 34: EXTRACTION_PROGRESS_PAGE,
! 35: DONATIONS_PAGE
1.1 root 36: };
37:
38: HWND hCurPage = NULL; /* Handle to current wizard page */
39: int nCurPageNo = -1; /* The current wizard page */
40: char WizardDestInstallPath [TC_MAX_PATH];
41: char WizardDestExtractPath [TC_MAX_PATH];
42: char SelfFile [TC_MAX_PATH];
43:
44: HBITMAP hbmWizardBitmapRescaled = NULL;
45:
46: BOOL bExtractOnly = FALSE;
47: BOOL bLicenseAccepted = FALSE;
48: BOOL bOpenContainingFolder = TRUE;
49: BOOL bExtractionSuccessful = FALSE;
50: BOOL bStartInstall = FALSE;
51: BOOL bStartExtraction = FALSE;
52: BOOL bInProgress = FALSE;
53:
54: int nPbar = 0; /* Control ID of progress bar */
55:
1.1.1.11! root 56: BOOL DonEnabled = TRUE;
! 57: static HFONT hDonTextFont;
! 58: static HFONT hDonHyperlinkFont;
! 59: static BOOL OsPrngAvailable;
! 60: static HCRYPTPROV hCryptProv;
! 61: static int DonCtrlType;
! 62: static int DonTextId;
! 63: static int DonCaptionId;
! 64: int DonPagePos;
! 65: static int DonColorSchemeId;
! 66: static int DonFontId;
! 67: static COLORREF DonTextColor;
! 68: static COLORREF DonLinkColor;
! 69: static COLORREF DonBkgColor;
! 70:
! 71: wstring DonText = L"";
! 72: wstring DonCaption = L"";
! 73:
1.1.1.3 root 74: void localcleanupwiz (void)
1.1 root 75: {
76: /* Delete buffered bitmaps (if any) */
77: if (hbmWizardBitmapRescaled != NULL)
78: {
79: DeleteObject ((HGDIOBJ) hbmWizardBitmapRescaled);
80: hbmWizardBitmapRescaled = NULL;
81: }
1.1.1.11! root 82:
! 83: if (DonEnabled)
! 84: {
! 85: if (hCryptProv != 0)
! 86: CryptReleaseContext (hCryptProv, 0);
! 87:
! 88: OsPrngAvailable = FALSE;
! 89: hCryptProv = 0;
! 90:
! 91: DeleteObject (hDonTextFont);
! 92: DeleteObject (hDonHyperlinkFont);
! 93: }
1.1 root 94: }
95:
96: static void InitWizardDestInstallPath (void)
97: {
98:
99: if (strlen (WizardDestInstallPath) < 2)
100: {
101: strcpy (WizardDestInstallPath, InstallationPath);
102: if (WizardDestInstallPath [strlen (WizardDestInstallPath) - 1] != '\\')
103: {
104: strcat (WizardDestInstallPath, "\\");
105: }
106: }
107: }
108:
109: void LoadPage (HWND hwndDlg, int nPageNo)
110: {
111: RECT rD, rW;
112:
113: if (hCurPage != NULL)
114: {
115: DestroyWindow (hCurPage);
116: }
117:
1.1.1.11! root 118: InvalidateRect (GetDlgItem (MainDlg, IDC_MAIN_CONTENT_CANVAS), NULL, TRUE);
! 119:
1.1 root 120: GetWindowRect (GetDlgItem (hwndDlg, IDC_POS_BOX), &rW);
121:
122: nCurPageNo = nPageNo;
123:
124: switch (nPageNo)
125: {
126: case INTRO_PAGE:
127: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INTRO_PAGE_DLG), hwndDlg,
128: (DLGPROC) PageDialogProc);
129: break;
130:
131: case WIZARD_MODE_PAGE:
132: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_WIZARD_MODE_PAGE_DLG), hwndDlg,
133: (DLGPROC) PageDialogProc);
134: break;
135:
136: case INSTALL_OPTIONS_PAGE:
137: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INSTALL_OPTIONS_PAGE_DLG), hwndDlg,
138: (DLGPROC) PageDialogProc);
139: break;
140:
141: case INSTALL_PROGRESS_PAGE:
142: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PROGRESS_PAGE_DLG), hwndDlg,
143: (DLGPROC) PageDialogProc);
144: break;
145:
146: case EXTRACTION_OPTIONS_PAGE:
147: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_EXTRACTION_OPTIONS_PAGE_DLG), hwndDlg,
148: (DLGPROC) PageDialogProc);
149: break;
150:
151: case EXTRACTION_PROGRESS_PAGE:
152: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PROGRESS_PAGE_DLG), hwndDlg,
153: (DLGPROC) PageDialogProc);
154: break;
1.1.1.11! root 155:
! 156: case DONATIONS_PAGE:
! 157: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_DONATIONS_PAGE_DLG), hwndDlg,
! 158: (DLGPROC) PageDialogProc);
! 159: break;
1.1 root 160: }
161:
162: rD.left = 15;
163: rD.top = 45;
164: rD.right = 0;
165: rD.bottom = 0;
166: MapDialogRect (hwndDlg, &rD);
167:
168: if (hCurPage != NULL)
169: {
170: MoveWindow (hCurPage, rD.left, rD.top, rW.right - rW.left, rW.bottom - rW.top, TRUE);
171: ShowWindow (hCurPage, SW_SHOWNORMAL);
172: }
173:
174: /* Refresh the graphics (white background of some texts, etc.) */
175: RefreshUIGFX ();
176: }
177:
178:
1.1.1.11! root 179: static int GetDonVal (int minVal, int maxVal)
! 180: {
! 181: static BOOL prngInitialized = FALSE;
! 182: static unsigned __int8 buffer [2];
! 183:
! 184: if (!prngInitialized)
! 185: {
! 186: if (!CryptAcquireContext (&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)
! 187: && !CryptAcquireContext (&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET))
! 188: OsPrngAvailable = FALSE;
! 189: else
! 190: OsPrngAvailable = TRUE;
! 191:
! 192: srand ((unsigned int) time (NULL));
! 193: rand(); // Generate and discard the inital value, as it always appears to be somewhat non-random.
! 194:
! 195: prngInitialized = TRUE;
! 196: }
! 197:
! 198: if (OsPrngAvailable && CryptGenRandom (hCryptProv, sizeof (buffer), buffer) != 0)
! 199: {
! 200: return ((int) ((double) *((uint16 *) buffer) / (0xFFFF+1) * (maxVal + 1 - minVal)) + minVal);
! 201: }
! 202: else
! 203: return ((int) ((double) rand() / (RAND_MAX+1) * (maxVal + 1 - minVal)) + minVal);
! 204: }
! 205:
! 206:
1.1 root 207: /* Except in response to the WM_INITDIALOG message, the dialog box procedure
208: should return nonzero if it processes the message, and zero if it does
209: not. - see DialogProc */
210: BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
211: {
212: static char PageDebugId[128];
213: WORD lw = LOWORD (wParam);
214: WORD hw = HIWORD (wParam);
215:
216: hCurPage = hwndDlg;
217:
218: switch (uMsg)
219: {
220: case WM_INITDIALOG:
221: LocalizeDialog (hwndDlg, "IDD_INSTL_DLG");
222:
223: sprintf (PageDebugId, "SETUP_WIZARD_PAGE_%d", nCurPageNo);
224: LastDialogId = PageDebugId;
225:
226: switch (nCurPageNo)
227: {
228: case INTRO_PAGE:
229: {
230: char *licenseText = NULL;
231:
232: licenseText = GetLegalNotices ();
233: if (licenseText != NULL)
234: {
235: SetWindowText (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), licenseText);
236: free (licenseText);
237: }
238: else
239: {
240: Error("CANNOT_DISPLAY_LICENSE");
1.1.1.5 root 241: exit (1);
1.1 root 242: }
243:
1.1.1.11! root 244: /* For legal reasons, some of the following texts cannot be localized by third parties. */
1.1 root 245:
1.1.1.5 root 246: SetCheckBox (hwndDlg, IDC_AGREE, bLicenseAccepted);
1.1 root 247:
1.1.1.11! root 248: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), L"Please read the license terms");
1.1.1.2 root 249: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), L"You must accept these license terms before you can use, extract, or install TrueCrypt.");
1.1.1.11! root 250: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), L"IMPORTANT: By checking the checkbox below, you accept these license terms and signify that you understand and agree to them. Please click the 'arrow down' icon to see the rest of the license."); // Cannot be localized by third parties (for legal reasons).
1.1 root 251: //SendMessage (GetDlgItem (hwndDlg, IDC_BOX_HELP), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
252:
1.1.1.11! root 253: SetWindowTextW (GetDlgItem (hwndDlg, IDC_AGREE), L"I &accept the license terms"); // Cannot be localized by third parties (for legal reasons).
1.1.1.5 root 254: //SetWindowTextW (GetDlgItem (hwndDlg, IDC_DISAGREE), L"I &do not accept the license terms");
1.1 root 255:
256: //SendMessage (GetDlgItem (hwndDlg, IDC_AGREE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
257: //SendMessage (GetDlgItem (hwndDlg, IDC_DISAGREE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
258:
259: EnableWindow (GetDlgItem (hwndDlg, IDC_AGREE), TRUE);
260:
1.1.1.11! root 261: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
1.1 root 262: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
263: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
264:
265: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), bLicenseAccepted);
266: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
267: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), bLicenseAccepted);
1.1.1.5 root 268:
269: // Left margin for license text
270: SendMessage (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), EM_SETMARGINS, (WPARAM) EC_LEFTMARGIN, (LPARAM) CompensateXDPI (4));
1.1 root 271: }
272: return 1;
273:
274: case WIZARD_MODE_PAGE:
275: {
1.1.1.8 root 276: LONG driverVersion;
1.1 root 277:
1.1.1.8 root 278: DetermineUpgradeDowngradeStatus (TRUE, &driverVersion);
1.1 root 279:
1.1.1.8 root 280: if (bRepairMode)
281: {
282: SetWindowTextW (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), GetString ("REPAIR_REINSTALL"));
283: bExtractOnly = FALSE;
284: }
285: else if (bUpgrade)
286: SetWindowTextW (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), GetString ("UPGRADE"));
1.1 root 287:
1.1.1.8 root 288: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_MODE_TITLE"));
289: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_MODE_INFO"));
1.1 root 290:
1.1.1.8 root 291: SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
292: SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
1.1 root 293:
1.1.1.8 root 294: CheckButton (GetDlgItem (hwndDlg, bExtractOnly ? IDC_WIZARD_MODE_EXTRACT_ONLY : IDC_WIZARD_MODE_INSTALL));
1.1 root 295:
1.1.1.8 root 296: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SETUP_MODE_HELP_EXTRACT"));
1.1 root 297:
1.1.1.8 root 298: if (!bRepairMode)
299: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP2), GetString (bUpgrade ? "SETUP_MODE_HELP_UPGRADE" : "SETUP_MODE_HELP_INSTALL"));
300:
301: EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), !bRepairMode);
302: EnableWindow (GetDlgItem (hwndDlg, IDC_BOX_HELP), !bRepairMode);
303: EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), TRUE);
1.1 root 304:
1.1.1.8 root 305: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
306: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
307: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
308: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
309: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
310: }
1.1 root 311: return 1;
312:
313: case EXTRACTION_OPTIONS_PAGE:
314:
315: if (strlen(WizardDestExtractPath) < 2)
316: {
317: strcpy (WizardDestExtractPath, SetupFilesDir);
318: strncat (WizardDestExtractPath, "TrueCrypt\\", sizeof (WizardDestExtractPath) - strlen (WizardDestExtractPath) - 1);
319: }
320:
321: SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
322:
323: SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
324:
325: SetCheckBox (hwndDlg, IDC_OPEN_CONTAINING_FOLDER, bOpenContainingFolder);
326:
327: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTION_OPTIONS_TITLE"));
328: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_OPTIONS_INFO"));
329: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
330:
1.1.1.11! root 331: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ((DonEnabled && DonPagePos == 2) ? "NEXT" : "EXTRACT"));
1.1 root 332: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
1.1.1.11! root 333:
! 334: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
1.1 root 335: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
336: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
337: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
338:
339: return 1;
340:
341: case EXTRACTION_PROGRESS_PAGE:
342:
343: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTING_VERB"));
344: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_PROGRESS_INFO"));
345: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
346:
347: if (bStartExtraction)
348: {
349: /* Start extraction */
350:
351: LastDialogId = "EXTRACTION_IN_PROGRESS";
352:
353: WaitCursor ();
354:
355: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
356: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
357: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
358: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
359:
360: if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
361: strcat (WizardDestExtractPath, "\\");
362:
363: strcpy (DestExtractPath, WizardDestExtractPath);
364:
365: InitProgressBar ();
366:
367: bInProgress = TRUE;
368: bStartExtraction = FALSE;
369:
1.1.1.5 root 370: _beginthread (ExtractAllFilesThread, 0, (void *) hwndDlg);
1.1 root 371: }
372: else
373: {
374: NormalCursor ();
375:
376: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
377: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
378: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
379: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
380: }
381:
382: return 1;
383:
384: case INSTALL_OPTIONS_PAGE:
1.1.1.8 root 385: {
386: LONG driverVersion;
1.1 root 387:
1.1.1.8 root 388: DetermineUpgradeDowngradeStatus (TRUE, &driverVersion);
1.1 root 389:
1.1.1.9 root 390: if (!bDesktopIconStatusDetermined)
391: {
392: bDesktopIcon = !bUpgrade;
393: bDesktopIconStatusDetermined = TRUE;
394: }
395:
1.1.1.8 root 396: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_OPTIONS_TITLE"));
397: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_OPTIONS_INFO"));
398: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
1.1 root 399:
1.1.1.8 root 400: InitWizardDestInstallPath ();
1.1 root 401:
1.1.1.8 root 402: SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
1.1 root 403:
1.1.1.8 root 404: SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
405:
1.1.1.9 root 406: if (bUpgrade)
407: {
408: SetWindowTextW (GetDlgItem (hwndDlg, IDT_INSTALL_DESTINATION), GetString ("SETUP_UPGRADE_DESTINATION"));
409: EnableWindow (GetDlgItem (hwndDlg, IDC_DESTINATION), FALSE);
410: EnableWindow (GetDlgItem (hwndDlg, IDC_BROWSE), FALSE);
1.1.1.10 root 411: EnableWindow (GetDlgItem (hwndDlg, IDC_ALL_USERS), FALSE);
412:
413: char path[MAX_PATH];
414: SHGetSpecialFolderPath (hwndDlg, path, CSIDL_COMMON_PROGRAMS, 0);
415: bForAllUsers = (_access ((string (path) + "\\" TC_APP_NAME).c_str(), 0) == 0);
1.1.1.9 root 416: }
417:
1.1.1.8 root 418: // System Restore
419: SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, bSystemRestore);
420: if (SystemRestoreDll == 0)
421: {
422: SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, FALSE);
423: EnableWindow (GetDlgItem (hwndDlg, IDC_SYSTEM_RESTORE), FALSE);
424: }
1.1 root 425:
1.1.1.8 root 426: SetCheckBox (hwndDlg, IDC_ALL_USERS, bForAllUsers);
427: SetCheckBox (hwndDlg, IDC_FILE_TYPE, bRegisterFileExt);
428: SetCheckBox (hwndDlg, IDC_PROG_GROUP, bAddToStartMenu);
429: SetCheckBox (hwndDlg, IDC_DESKTOP_ICON, bDesktopIcon);
1.1 root 430:
1.1.1.11! root 431: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ((DonEnabled && DonPagePos == 2) ? "NEXT" : (bUpgrade ? "UPGRADE" : "INSTALL")));
1.1.1.8 root 432: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
1.1 root 433:
1.1.1.8 root 434: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
435: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
436: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
437: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
438: }
1.1 root 439: return 1;
440:
441: case INSTALL_PROGRESS_PAGE:
442:
443: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_PROGRESS_TITLE"));
444: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_PROGRESS_INFO"));
445: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
446: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
447:
448: if (bStartInstall)
449: {
450: /* Start install */
451:
452: LastDialogId = "INSTALL_IN_PROGRESS";
453:
454: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
455:
456: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
457: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
458: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
459: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
460:
461: InitProgressBar ();
462:
463: if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
464: strcat (WizardDestInstallPath, "\\");
465:
466: strcpy (InstallationPath, WizardDestInstallPath);
467:
468: WaitCursor ();
469:
470: bInProgress = TRUE;
471: bStartInstall = FALSE;
472:
1.1.1.5 root 473: _beginthread (DoInstall, 0, (void *) hwndDlg);
1.1 root 474: }
475: else
476: {
477: NormalCursor ();
478:
479: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
480: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
481: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
482: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
483:
484: }
485:
486: return 1;
487:
1.1.1.11! root 488: case DONATIONS_PAGE:
! 489:
! 490: if (DonPagePos != 2)
! 491: {
! 492: // Final page
! 493:
! 494: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bExtractOnly ? "EXTRACTION_FINISHED_TITLE_DON" : (bUpgrade ? "SETUP_FINISHED_UPGRADE_TITLE_DON" : "SETUP_FINISHED_TITLE_DON")));
! 495: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_FINISHED_INFO_DON"));
! 496: }
! 497: else
! 498: {
! 499: // Non-final page
! 500:
! 501: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString (bExtractOnly ? "EXTRACT" : (bUpgrade ? "UPGRADE" : "INSTALL")));
! 502:
! 503: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("CONSIDER_MAKING_A_DONATION"));
! 504: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString (bExtractOnly ? "SETUP_DON_EXTRACT_INFO" : (bUpgrade ? "SETUP_DON_UPGRADE_INFO" : "SETUP_DON_INSTALL_INFO")));
! 505: }
! 506:
! 507: switch (DonTextId)
! 508: {
! 509: case 2:
! 510: DonText = L"Please help us by making a donation.";
! 511: break;
! 512: case 3:
! 513: DonText = L"Please help us by donating.";
! 514: break;
! 515: case 4:
! 516: DonText = L"Please consider making a donation.";
! 517: break;
! 518: case 5:
! 519: DonText = L"Please consider donating.";
! 520: break;
! 521: }
! 522:
! 523: switch (DonCaptionId)
! 524: {
! 525: case 2:
! 526: DonCaption = L"Make a donation";
! 527: break;
! 528: case 3:
! 529: DonCaption = L"Donate now";
! 530: break;
! 531: }
! 532:
! 533: if (DonCtrlType != 2)
! 534: DonCaption += L"...";
! 535:
! 536:
! 537: // Colors
! 538:
! 539: switch (DonColorSchemeId)
! 540: {
! 541: case 2:
! 542: // Default OS colors (foreground and background) + blue hyperlink
! 543: DonLinkColor = RGB (12, 95, 255);
! 544: break;
! 545:
! 546: case 3:
! 547: // Red
! 548: DonTextColor = RGB (255, 255, 255);
! 549: DonLinkColor = RGB (0, 0, 255);
! 550: DonBkgColor = RGB (255, 0, 0);
! 551: break;
! 552:
! 553: case 4:
! 554: // Yellow
! 555: DonTextColor = RGB (255, 15, 49);
! 556: DonLinkColor = RGB (32, 135, 238);
! 557: DonBkgColor = RGB (255, 255, 0);
! 558: break;
! 559:
! 560: case 5:
! 561: // Light red
! 562: DonTextColor = RGB (255, 255, 255);
! 563: DonLinkColor = RGB (12, 95, 255);
! 564: DonBkgColor = RGB (255, 141, 144);
! 565: break;
! 566:
! 567: case 6:
! 568: // Pink
! 569: DonTextColor = RGB (255, 255, 255);
! 570: DonLinkColor = RGB (72, 135, 255);
! 571: DonBkgColor = RGB (248, 148, 207);
! 572: break;
! 573:
! 574: case 7:
! 575: // White + red text
! 576: DonTextColor = RGB (255, 15, 49);
! 577: DonLinkColor = RGB (12, 115, 218);
! 578: DonBkgColor = RGB (255, 255, 255);
! 579: break;
! 580:
! 581: case 8:
! 582: // Blue
! 583: DonTextColor = RGB (255, 255, 255);
! 584: DonLinkColor = RGB (20, 40, 204);
! 585: DonBkgColor = RGB (54, 140, 255);
! 586: break;
! 587:
! 588: case 9:
! 589: // Green
! 590: DonTextColor = RGB (255, 255, 255);
! 591: DonLinkColor = RGB (12, 95, 255);
! 592: DonBkgColor = RGB (70, 180, 80);
! 593: break;
! 594: }
! 595:
! 596:
! 597: {
! 598: // Fonts
! 599:
! 600: LOGFONTW lf;
! 601: memset (&lf, 0, sizeof(lf));
! 602: wstring fontFaceName = L"";
! 603:
! 604: switch (DonFontId)
! 605: {
! 606: case 2:
! 607: fontFaceName = L"Tahoma";
! 608: break;
! 609: case 3:
! 610: fontFaceName = L"Times New Roman";
! 611: break;
! 612: }
! 613:
! 614: // Main font
! 615: wcsncpy (lf.lfFaceName, fontFaceName.c_str(), sizeof (lf.lfFaceName)/2);
! 616: lf.lfHeight = CompensateDPIFont (-21);
! 617: lf.lfWeight = FW_NORMAL;
! 618: lf.lfWidth = 0;
! 619: lf.lfEscapement = 0;
! 620: lf.lfOrientation = 0;
! 621: lf.lfItalic = FALSE;
! 622: lf.lfUnderline = FALSE;
! 623: lf.lfStrikeOut = FALSE;
! 624: lf.lfCharSet = DEFAULT_CHARSET;
! 625: lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
! 626: lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
! 627: lf.lfQuality = PROOF_QUALITY;
! 628: lf.lfPitchAndFamily = FF_DONTCARE;
! 629: hDonTextFont = CreateFontIndirectW (&lf);
! 630:
! 631: // Hyperlink font
! 632: wcsncpy (lf.lfFaceName, fontFaceName.c_str(), sizeof (lf.lfFaceName)/2);
! 633: lf.lfHeight = CompensateDPIFont (-18);
! 634: lf.lfUnderline = TRUE;
! 635: hDonHyperlinkFont = CreateFontIndirectW (&lf);
! 636: }
! 637:
! 638:
! 639: switch (DonCtrlType)
! 640: {
! 641: case 2: // Hyperlink
! 642:
! 643: ShowWindow(GetDlgItem(hwndDlg, IDC_DONATE), SW_HIDE);
! 644: ShowWindow(GetDlgItem(hwndDlg, IDC_DONATIONS_LINK), SW_SHOW);
! 645: SetWindowTextW (GetDlgItem(hwndDlg, IDC_DONATIONS_LINK), DonCaption.c_str());
! 646: ToCustHyperlink (hwndDlg, IDC_DONATIONS_LINK, hDonHyperlinkFont);
! 647: break;
! 648:
! 649: case 3: // Button
! 650:
! 651: ShowWindow(GetDlgItem(hwndDlg, IDC_DONATIONS_LINK), SW_HIDE);
! 652: ShowWindow(GetDlgItem(hwndDlg, IDC_DONATE), SW_SHOW);
! 653: SetWindowTextW (GetDlgItem(hwndDlg, IDC_DONATE), DonCaption.c_str());
! 654: break;
! 655: }
! 656:
! 657: return 1;
1.1 root 658: }
1.1.1.11! root 659:
1.1 root 660: return 0;
661:
662: case WM_HELP:
663: if (bLicenseAccepted)
664: OpenPageHelp (GetParent (hwndDlg), nCurPageNo);
665:
666: return 1;
667:
1.1.1.3 root 668: case WM_ENDSESSION:
669: EndDialog (MainDlg, 0);
670: localcleanup ();
671: return 0;
672:
1.1 root 673:
674: case WM_COMMAND:
675:
676: if (lw == IDC_AGREE && nCurPageNo == INTRO_PAGE)
677: {
1.1.1.5 root 678: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), IsButtonChecked (GetDlgItem (hwndDlg, IDC_AGREE)));
1.1 root 679: return 1;
680: }
681:
682: if (lw == IDC_WIZARD_MODE_EXTRACT_ONLY && nCurPageNo == WIZARD_MODE_PAGE)
683: {
684: bExtractOnly = TRUE;
685: return 1;
686: }
687:
688: if (lw == IDC_WIZARD_MODE_INSTALL && nCurPageNo == WIZARD_MODE_PAGE)
689: {
690: bExtractOnly = FALSE;
691: return 1;
692: }
693:
694: if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE && hw == EN_CHANGE )
695: {
696: EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
697: return 1;
698: }
699:
700: if ( nCurPageNo == INSTALL_OPTIONS_PAGE && hw == EN_CHANGE )
701: {
702: EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
703: return 1;
704: }
705:
706: if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE )
707: {
708: switch (lw)
709: {
710: case IDC_BROWSE:
711: if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestExtractPath))
712: {
713: if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
714: {
715: strcat (WizardDestExtractPath, "\\");
716: }
717: SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
718: }
719: return 1;
720:
721: case IDC_OPEN_CONTAINING_FOLDER:
1.1.1.2 root 722: bOpenContainingFolder = IsButtonChecked (GetDlgItem (hCurPage, IDC_OPEN_CONTAINING_FOLDER));
1.1 root 723: return 1;
724: }
725: }
726:
727: if ( nCurPageNo == INSTALL_OPTIONS_PAGE )
728: {
729: switch (lw)
730: {
731: case IDC_BROWSE:
732: if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestInstallPath))
733: {
734: if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
735: {
736: strcat (WizardDestInstallPath, "\\");
737: }
738: SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
739: }
740: return 1;
741:
742: case IDC_SYSTEM_RESTORE:
743: bSystemRestore = IsButtonChecked (GetDlgItem (hCurPage, IDC_SYSTEM_RESTORE));
744: return 1;
745:
746: case IDC_ALL_USERS:
747: bForAllUsers = IsButtonChecked (GetDlgItem (hCurPage, IDC_ALL_USERS));
748: return 1;
749:
750: case IDC_FILE_TYPE:
751: bRegisterFileExt = IsButtonChecked (GetDlgItem (hCurPage, IDC_FILE_TYPE));
752: return 1;
753:
754: case IDC_PROG_GROUP:
755: bAddToStartMenu = IsButtonChecked (GetDlgItem (hCurPage, IDC_PROG_GROUP));
756: return 1;
757:
758: case IDC_DESKTOP_ICON:
759: bDesktopIcon = IsButtonChecked (GetDlgItem (hCurPage, IDC_DESKTOP_ICON));
760: return 1;
761:
762: }
763: }
764:
1.1.1.11! root 765: if (nCurPageNo == DONATIONS_PAGE)
! 766: {
! 767: switch (lw)
! 768: {
! 769: case IDC_DONATE:
! 770: case IDC_DONATIONS_LINK:
! 771: {
! 772: char tmpstr [200];
! 773:
! 774: sprintf (tmpstr, "&ref=%d-%d-%d-%d-%d-%d", DonCaptionId, DonFontId, DonCtrlType, DonPagePos, DonTextId, DonColorSchemeId);
! 775:
! 776: Applink ("donate", FALSE, tmpstr);
! 777: }
! 778: return 1;
! 779: }
! 780: }
! 781:
! 782: return 0;
! 783:
! 784:
! 785: case WM_PAINT:
! 786:
! 787: if (nCurPageNo == DONATIONS_PAGE)
! 788: {
! 789: PAINTSTRUCT tmpPaintStruct;
! 790: HDC hdc = BeginPaint (hCurPage, &tmpPaintStruct);
! 791:
! 792: SelectObject (hdc, hDonTextFont);
! 793:
! 794: if (DonColorSchemeId != 2)
! 795: {
! 796: HBRUSH tmpBrush = CreateSolidBrush (DonBkgColor);
! 797:
! 798: RECT trect;
! 799:
! 800: trect.left = 0;
! 801: trect.right = CompensateXDPI (526);
! 802: trect.top = 0;
! 803: trect.bottom = CompensateYDPI (246);
! 804:
! 805: FillRect (hdc, &trect, tmpBrush);
! 806:
! 807: SetTextColor (hdc, DonTextColor);
! 808: SetBkColor (hdc, DonBkgColor);
! 809: }
! 810:
! 811: SetTextAlign(hdc, TA_CENTER);
! 812:
! 813: TextOutW (hdc,
! 814: CompensateXDPI (258),
! 815: CompensateYDPI ((DonColorSchemeId == 2 || DonCtrlType != 2) ? 70 : 93),
! 816: DonText.c_str(),
! 817: DonText.length());
! 818:
! 819: EndPaint (hCurPage, &tmpPaintStruct);
! 820: ReleaseDC (hCurPage, hdc);
! 821:
! 822: }
! 823: return 0;
! 824:
! 825:
! 826: case WM_CTLCOLORSTATIC:
! 827:
! 828: if (nCurPageNo == DONATIONS_PAGE && (HWND) lParam == GetDlgItem (hCurPage, IDC_DONATIONS_LINK))
! 829: {
! 830: // Hyperlink color
! 831: SetTextColor ((HDC) wParam, DonLinkColor);
! 832: }
! 833:
! 834: /* This maintains the background under the transparent-backround texts */
! 835:
! 836: SetBkMode ((HDC) wParam, TRANSPARENT);
! 837: return ((LONG) (HBRUSH) (GetStockObject (NULL_BRUSH)));
! 838:
! 839:
! 840: case WM_ERASEBKGND:
! 841:
1.1 root 842: return 0;
843: }
844:
845: return 0;
846: }
847:
848: void InitProgressBar (void)
849: {
850: HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
851: SendMessage (hProgressBar, PBM_SETRANGE32, 0, 100);
852: SendMessage (hProgressBar, PBM_SETSTEP, 1, 0);
853: InvalidateRect (hProgressBar, NULL, TRUE);
854: }
855:
856: // Must always return TRUE
857: BOOL UpdateProgressBarProc (int nPercent)
858: {
859: HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
860: SendMessage (hProgressBar, PBM_SETPOS, (int) (100.0 * nPercent / 100), 0);
861: InvalidateRect (hProgressBar, NULL, TRUE);
862: ShowWindow(hProgressBar, SW_HIDE);
863: ShowWindow(hProgressBar, SW_SHOW);
864: // Prevent the IDC_LOG_WINDOW item from partially disappearing at higher DPIs
865: ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_HIDE);
866: ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_SHOW);
867: RefreshUIGFX();
868: return TRUE;
869: }
870:
871: void RefreshUIGFX (void)
872: {
873: InvalidateRect (GetDlgItem (MainDlg, IDC_SETUP_WIZARD_BKG), NULL, TRUE);
874: InvalidateRect (GetDlgItem (MainDlg, IDC_BOX_TITLE), NULL, TRUE);
875: InvalidateRect (GetDlgItem (MainDlg, IDC_BOX_INFO), NULL, TRUE);
876: InvalidateRect (GetDlgItem (MainDlg, IDC_BITMAP_SETUP_WIZARD), NULL, TRUE);
877: InvalidateRect (GetDlgItem (MainDlg, IDC_HR), NULL, TRUE);
878: // Prevent these items from disappearing at higher DPIs
879: ShowWindow(GetDlgItem(MainDlg, IDC_HR), SW_HIDE);
880: ShowWindow(GetDlgItem(MainDlg, IDC_HR), SW_SHOW);
881: ShowWindow(GetDlgItem(MainDlg, IDC_HR_BOTTOM), SW_HIDE);
882: ShowWindow(GetDlgItem(MainDlg, IDC_HR_BOTTOM), SW_SHOW);
883: ShowWindow(GetDlgItem(MainDlg, IDC_BOX_INFO), SW_HIDE);
884: ShowWindow(GetDlgItem(MainDlg, IDC_BOX_INFO), SW_SHOW);
885: ShowWindow(GetDlgItem(MainDlg, IDC_BOX_TITLE), SW_HIDE);
886: ShowWindow(GetDlgItem(MainDlg, IDC_BOX_TITLE), SW_SHOW);
887: }
888:
889:
890: /* Except in response to the WM_INITDIALOG message, the dialog box procedure
891: should return nonzero if it processes the message, and zero if it does
892: not. - see DialogProc */
893: BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
894: {
895: WORD lw = LOWORD (wParam);
896:
897: switch (uMsg)
898: {
899: case WM_INITDIALOG:
900: {
901: RECT rec;
902:
903: GetModuleFileName (NULL, SelfFile, sizeof (SelfFile));
904:
905: MainDlg = hwndDlg;
1.1.1.3 root 906:
907: if (!CreateAppSetupMutex ())
908: AbortProcess ("TC_INSTALLER_IS_RUNNING");
909:
1.1 root 910: InitDialog (hwndDlg);
911: LocalizeDialog (hwndDlg, "IDD_INSTL_DLG");
912:
913: // Resize the bitmap if the user has a non-default DPI
914: if (ScreenDPI != USER_DEFAULT_SCREEN_DPI)
915: {
916: hbmWizardBitmapRescaled = RenderBitmap (MAKEINTRESOURCE (IDB_SETUP_WIZARD),
917: GetDlgItem (hwndDlg, IDC_BITMAP_SETUP_WIZARD),
918: 0, 0, 0, 0, FALSE, TRUE);
919: }
920:
921: // Gfx area background (must not keep aspect ratio; must retain Windows-imposed distortion)
922: GetClientRect (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_GFX_AREA), &rec);
923: SetWindowPos (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_BKG), HWND_TOP, 0, 0, rec.right, rec.bottom, SWP_NOMOVE);
924:
925: nPbar = IDC_PROGRESS_BAR;
926:
927: SendMessage (GetDlgItem (hwndDlg, IDC_BOX_TITLE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
928:
1.1.1.6 root 929: SetWindowText (hwndDlg, "TrueCrypt Setup " VERSION_STRING);
1.1 root 930:
1.1.1.11! root 931: if (DonEnabled)
! 932: {
! 933: // 2 - displayed before installation, all messageboxes and prompts displayed as usual (as in earlier versions without a donations page).
! 934: // 3 - displayed after installation *and* after a messagebox ('install/upgrade/extraction successful') is closed by the user. The following prompts are postponed to time when the user clicks Finish: restart required, tutorial, release notes.
! 935: // 4 - displayed after installation. No message box is displayed after successful install/update. The following prompts are postponed to time when the user clicks Finish: restart required, tutorial, release notes.
! 936: DonPagePos = GetDonVal (2, 4);
! 937:
! 938: DonCaptionId = GetDonVal (2, 3);
! 939: DonFontId = GetDonVal (2, 3);
! 940: DonCtrlType = GetDonVal (2, 3); // 2 - hyperlink, 3 - button
! 941: DonTextId = GetDonVal (2, 5);
! 942: DonColorSchemeId = GetDonVal (2, 9);
! 943: }
! 944:
1.1 root 945: if (bDevm)
946: {
947: InitWizardDestInstallPath ();
948: bSystemRestore = FALSE;
949: bRegisterFileExt = FALSE;
950: bAddToStartMenu = FALSE;
951: bDesktopIcon = TRUE;
952: bLicenseAccepted = TRUE;
953: bStartInstall = TRUE;
954: LoadPage (hwndDlg, INSTALL_PROGRESS_PAGE);
955: }
956: else
957: LoadPage (hwndDlg, INTRO_PAGE);
1.1.1.3 root 958:
1.1 root 959: }
960: return 0;
961:
962: case WM_SYSCOMMAND:
963: if (lw == IDC_ABOUT)
964: {
965: if (bLicenseAccepted)
966: DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc);
967:
968: return 1;
969: }
970: return 0;
971:
972: case WM_HELP:
973: if (bLicenseAccepted)
974: OpenPageHelp (hwndDlg, nCurPageNo);
975:
976: return 1;
977:
978: case WM_COMMAND:
979: if (lw == IDHELP)
980: {
981: if (bLicenseAccepted)
982: OpenPageHelp (hwndDlg, nCurPageNo);
983:
984: return 1;
985: }
986: if (lw == IDCANCEL)
987: {
988: PostMessage (hwndDlg, WM_CLOSE, 0, 0);
989: return 1;
990: }
991: if (lw == IDC_NEXT)
992: {
993: if (nCurPageNo == INTRO_PAGE)
994: {
995: if (!IsButtonChecked (GetDlgItem (hCurPage, IDC_AGREE)))
996: {
997: bLicenseAccepted = FALSE;
998: return 1;
999: }
1000: bLicenseAccepted = TRUE;
1001: EnableWindow (GetDlgItem (hwndDlg, IDHELP), TRUE);
1.1.1.8 root 1002:
1003: if (nCurrentOS == WIN_2000)
1.1.1.11! root 1004: {
1.1.1.10 root 1005: WarningDirect (L"Warning: Please note that this may be the last version of TrueCrypt that supports Windows 2000. If you want to be able to upgrade to future versions of TrueCrypt (which is highly recommended), you will need to upgrade to Windows XP or a later version of Windows.\n\nNote: Microsoft stopped issuing security updates for Windows 2000 to the general public on 7/13/2010 (the last non-security update for Windows 2000 was issued to the general public in 2005).");
1.1.1.11! root 1006:
! 1007:
! 1008: HKEY hkey;
! 1009:
! 1010: if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\Update Rollup 1", 0, KEY_READ, &hkey) != ERROR_SUCCESS)
! 1011: {
! 1012: ErrorDirect (L"TrueCrypt requires Update Rollup 1 for Windows 2000 SP4 to be installed.\n\nFor more information, see http://support.microsoft.com/kb/891861");
! 1013: AbortProcessSilent ();
! 1014: }
! 1015:
! 1016: RegCloseKey (hkey);
! 1017: }
1.1 root 1018: }
1019:
1020: else if (nCurPageNo == WIZARD_MODE_PAGE)
1021: {
1.1.1.5 root 1022: if (IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY)))
1.1 root 1023: {
1.1.1.5 root 1024: if (IsUacSupported()
1025: && AskWarnYesNo ("TRAVELER_UAC_NOTE") == IDNO)
1026: {
1027: return 1;
1028: }
1029:
1030: bExtractOnly = TRUE;
1.1 root 1031: nCurPageNo = EXTRACTION_OPTIONS_PAGE - 1;
1032: }
1033: }
1034:
1035: else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
1036: {
1037: GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
1.1.1.11! root 1038:
! 1039: if (DonEnabled && DonPagePos == 2)
! 1040: {
! 1041: nCurPageNo = DONATIONS_PAGE;
! 1042: LoadPage (hwndDlg, DONATIONS_PAGE);
! 1043: return 1;
! 1044: }
! 1045: else
! 1046: {
! 1047: bStartExtraction = TRUE;
! 1048: }
1.1 root 1049: }
1.1.1.11! root 1050:
1.1 root 1051: else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
1052: {
1053: GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
1.1.1.11! root 1054:
! 1055: if (DonEnabled && DonPagePos == 2)
! 1056: {
! 1057: nCurPageNo = DONATIONS_PAGE;
! 1058: LoadPage (hwndDlg, DONATIONS_PAGE);
! 1059: return 1;
! 1060: }
! 1061: else
! 1062: {
! 1063: bStartInstall = TRUE;
! 1064: }
1.1 root 1065: }
1066:
1067: else if (nCurPageNo == INSTALL_PROGRESS_PAGE)
1068: {
1069: PostMessage (hwndDlg, WM_CLOSE, 0, 0);
1070: return 1;
1071: }
1072:
1073: else if (nCurPageNo == EXTRACTION_PROGRESS_PAGE)
1074: {
1075: PostMessage (hwndDlg, WM_CLOSE, 0, 0);
1076: return 1;
1077: }
1078:
1.1.1.11! root 1079: else if (nCurPageNo == DONATIONS_PAGE)
! 1080: {
! 1081: if (DonPagePos != 2)
! 1082: {
! 1083: // 'Finish' button clicked
! 1084:
! 1085: if (!IsHiddenOSRunning()) // A hidden OS user should not see the post-install notes twice (on decoy OS and then on hidden OS).
! 1086: {
! 1087: if (!bRestartRequired && !SystemEncryptionUpgrade) // In those cases, tutorial or release notes should have already been saved as post-install tasks
! 1088: {
! 1089: if (bUpgrade)
! 1090: {
! 1091: if (AskYesNo ("AFTER_UPGRADE_RELEASE_NOTES") == IDYES)
! 1092: {
! 1093: Applink ("releasenotes", TRUE, "");
! 1094: }
! 1095: }
! 1096: else if (bPossiblyFirstTimeInstall)
! 1097: {
! 1098: if (AskYesNo ("AFTER_INSTALL_TUTORIAL") == IDYES)
! 1099: {
! 1100: Applink ("beginnerstutorial", TRUE, "");
! 1101: }
! 1102: }
! 1103: }
! 1104: }
! 1105:
! 1106: if (bRestartRequired)
! 1107: {
! 1108: if (AskYesNo (bUpgrade ? "UPGRADE_OK_REBOOT_REQUIRED" : "CONFIRM_RESTART") == IDYES)
! 1109: RestartComputer();
! 1110: }
! 1111:
! 1112: PostMessage (hwndDlg, WM_CLOSE, 0, 0);
! 1113: }
! 1114: else
! 1115: {
! 1116: if (bExtractOnly)
! 1117: {
! 1118: bStartExtraction = TRUE;
! 1119: nCurPageNo = EXTRACTION_PROGRESS_PAGE;
! 1120: LoadPage (hwndDlg, EXTRACTION_PROGRESS_PAGE);
! 1121: }
! 1122: else
! 1123: {
! 1124: bStartInstall = TRUE;
! 1125: nCurPageNo = INSTALL_PROGRESS_PAGE;
! 1126: LoadPage (hwndDlg, INSTALL_PROGRESS_PAGE);
! 1127: }
! 1128: }
! 1129:
! 1130: return 1;
! 1131: }
! 1132:
1.1 root 1133: LoadPage (hwndDlg, ++nCurPageNo);
1134:
1135: return 1;
1136: }
1137:
1138: if (lw == IDC_PREV)
1139: {
1140: if (nCurPageNo == WIZARD_MODE_PAGE)
1141: {
1142: bExtractOnly = IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY));
1143: }
1144:
1145: else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
1146: {
1147: GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
1148: nCurPageNo = WIZARD_MODE_PAGE + 1;
1149: }
1150:
1151: else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
1152: {
1153: GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
1154: }
1155:
1.1.1.11! root 1156: else if (nCurPageNo == DONATIONS_PAGE && DonPagePos == 2)
! 1157: {
! 1158: if (bExtractOnly)
! 1159: nCurPageNo = EXTRACTION_OPTIONS_PAGE;
! 1160: else
! 1161: nCurPageNo = INSTALL_OPTIONS_PAGE;
! 1162:
! 1163: LoadPage (hwndDlg, nCurPageNo);
! 1164: return 1;
! 1165: }
! 1166:
! 1167:
1.1 root 1168: LoadPage (hwndDlg, --nCurPageNo);
1169:
1170: return 1;
1171: }
1172:
1173: return 0;
1174:
1.1.1.11! root 1175:
! 1176:
! 1177: case WM_PAINT:
! 1178:
! 1179: if (nCurPageNo == DONATIONS_PAGE && DonEnabled && DonColorSchemeId != 2)
! 1180: {
! 1181: HWND hwndItem = GetDlgItem (MainDlg, IDC_MAIN_CONTENT_CANVAS);
! 1182:
! 1183: PAINTSTRUCT tmpPaintStruct;
! 1184: HDC hdc = BeginPaint (hwndItem, &tmpPaintStruct);
! 1185:
! 1186: if (DonColorSchemeId != 2)
! 1187: {
! 1188: HBRUSH tmpBrush = CreateSolidBrush (DonBkgColor);
! 1189:
! 1190: RECT trect;
! 1191:
! 1192: trect.left = CompensateXDPI (1);
! 1193: trect.right = CompensateXDPI (560);
! 1194: trect.top = CompensateYDPI (DonColorSchemeId == 7 ? 11 : 0);
! 1195: trect.bottom = CompensateYDPI (260);
! 1196:
! 1197: FillRect (hdc, &trect, tmpBrush);
! 1198: }
! 1199:
! 1200: EndPaint(hwndItem, &tmpPaintStruct);
! 1201: ReleaseDC (hwndItem, hdc);
! 1202: }
! 1203: return 0;
! 1204:
! 1205:
! 1206:
1.1 root 1207: case WM_CTLCOLORSTATIC:
1208:
1.1.1.11! root 1209: if ((HWND) lParam != GetDlgItem (MainDlg, IDC_MAIN_CONTENT_CANVAS))
! 1210: {
! 1211: /* This maintains the background under the transparent-backround texts. The above 'if' statement allows
! 1212: colored background to be erased automatically when leaving a page that uses it. */
! 1213:
! 1214: SetBkMode ((HDC) wParam, TRANSPARENT);
! 1215: return ((LONG) (HBRUSH) (GetStockObject (NULL_BRUSH)));
! 1216: }
1.1 root 1217:
1218:
1219: case WM_ERASEBKGND:
1.1.1.11! root 1220:
1.1 root 1221: return 0;
1222:
1.1.1.11! root 1223:
! 1224:
1.1 root 1225: case TC_APPMSG_INSTALL_SUCCESS:
1226:
1227: /* Installation completed successfully */
1228:
1229: bInProgress = FALSE;
1230:
1.1.1.11! root 1231: if (DonEnabled && DonPagePos != 2)
! 1232: {
! 1233: nCurPageNo = DONATIONS_PAGE;
! 1234: LoadPage (hwndDlg, DONATIONS_PAGE);
! 1235: }
! 1236: else
! 1237: {
! 1238: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("SETUP_FINISHED_TITLE"));
! 1239: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString (bRestartRequired ? "SETUP_FINISHED_INFO_RESTART_REQUIRED" : "SETUP_FINISHED_INFO"));
! 1240: }
! 1241:
1.1 root 1242: NormalCursor ();
1243:
1.1.1.8 root 1244: SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
1.1.1.11! root 1245:
1.1 root 1246: EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
1247: EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
1248: EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
1249: EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
1250:
1251:
1252: RefreshUIGFX ();
1253: return 1;
1254:
1255: case TC_APPMSG_INSTALL_FAILURE:
1256:
1.1.1.11! root 1257: /* Installation failed */
! 1258:
1.1 root 1259: bInProgress = FALSE;
1260:
1261: NormalCursor ();
1262:
1.1.1.11! root 1263: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("INSTALL_FAILED"));
! 1264: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), L"");
! 1265:
! 1266: SetWindowTextW (GetDlgItem (hwndDlg, IDCANCEL), GetString ("IDCLOSE"));
! 1267: EnableWindow (GetDlgItem (hwndDlg, IDHELP), TRUE);
! 1268: EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
! 1269: EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), FALSE);
! 1270: EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), TRUE);
! 1271:
! 1272: RefreshUIGFX();
! 1273:
1.1 root 1274: return 1;
1275:
1276: case TC_APPMSG_EXTRACTION_SUCCESS:
1277:
1278: /* Extraction completed successfully */
1279:
1.1.1.11! root 1280: UpdateProgressBarProc(100);
1.1 root 1281:
1282: bInProgress = FALSE;
1283: bExtractionSuccessful = TRUE;
1284:
1285: NormalCursor ();
1286:
1287: StatusMessage (hCurPage, "EXTRACTION_FINISHED_INFO");
1288:
1289: EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
1290: EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
1291: EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
1292: EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
1293:
1.1.1.11! root 1294: if (DonEnabled && DonPagePos != 2)
! 1295: {
! 1296: RefreshUIGFX ();
1.1 root 1297:
1.1.1.11! root 1298: if (DonPagePos == 3)
! 1299: Info ("EXTRACTION_FINISHED_INFO");
! 1300:
! 1301: SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
1.1 root 1302:
1.1.1.11! root 1303: nCurPageNo = DONATIONS_PAGE;
! 1304: LoadPage (hwndDlg, DONATIONS_PAGE);
! 1305: }
! 1306: else
! 1307: {
! 1308: SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
! 1309: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("EXTRACTION_FINISHED_TITLE"));
! 1310: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString ("EXTRACTION_FINISHED_INFO"));
! 1311:
! 1312: RefreshUIGFX ();
! 1313:
! 1314: Info ("EXTRACTION_FINISHED_INFO");
! 1315: }
1.1 root 1316:
1317: return 1;
1318:
1319: case TC_APPMSG_EXTRACTION_FAILURE:
1320:
1321: /* Extraction failed */
1.1.1.11! root 1322:
1.1 root 1323: bInProgress = FALSE;
1324:
1325: NormalCursor ();
1326:
1327: StatusMessage (hCurPage, "EXTRACTION_FAILED");
1328:
1329: UpdateProgressBarProc(0);
1330:
1.1.1.11! root 1331: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("EXTRACTION_FAILED"));
! 1332: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), L"");
! 1333:
! 1334: SetWindowTextW (GetDlgItem (hwndDlg, IDCANCEL), GetString ("IDCLOSE"));
! 1335: EnableWindow (GetDlgItem (hwndDlg, IDHELP), TRUE);
! 1336: EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
! 1337: EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), FALSE);
! 1338: EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), TRUE);
! 1339:
! 1340: RefreshUIGFX();
! 1341:
1.1 root 1342: Error ("EXTRACTION_FAILED");
1343:
1344: return 1;
1345:
1346: case WM_CLOSE:
1.1.1.3 root 1347:
1.1 root 1348: if (bInProgress)
1349: {
1350: NormalCursor();
1351: if (AskNoYes("CONFIRM_EXIT_UNIVERSAL") == IDNO)
1352: {
1353: return 1;
1354: }
1355: WaitCursor ();
1356: }
1357:
1358: if (bOpenContainingFolder && bExtractOnly && bExtractionSuccessful)
1359: ShellExecute (NULL, "open", WizardDestExtractPath, NULL, NULL, SW_SHOWNORMAL);
1360:
1361: EndDialog (hwndDlg, IDCANCEL);
1362: return 1;
1363: }
1364:
1365: return 0;
1366: }
1367:
1368:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.