Annotation of truecrypt/setup/wizard.c, revision 1.1.1.8

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
                      6:  the original source code (contained in this file) and all other portions of
1.1.1.6   root        7:  this file are Copyright (c) 2003-2009 TrueCrypt Foundation and are governed
1.1.1.8 ! root        8:  by the TrueCrypt License 2.8 the full text of which is contained in the
1.1       root        9:  file License.txt included in TrueCrypt binary and source code distribution
                     10:  packages. */
                     11: 
                     12: #include "Tcdefs.h"
                     13: 
                     14: #include "SelfExtract.h"
                     15: #include "Wizard.h"
                     16: #include "Dlgcode.h"
                     17: #include "Language.h"
                     18: #include "Common/Resource.h"
                     19: #include "Resource.h"
1.1.1.8 ! root       20: #include "Setup.h"
1.1       root       21: 
                     22: enum wizard_pages
                     23: {
                     24:        INTRO_PAGE,
                     25:        WIZARD_MODE_PAGE,
                     26:        INSTALL_OPTIONS_PAGE,
                     27:        INSTALL_PROGRESS_PAGE,
                     28:        EXTRACTION_OPTIONS_PAGE,
                     29:        EXTRACTION_PROGRESS_PAGE
                     30: };
                     31: 
                     32: HWND hCurPage = NULL;          /* Handle to current wizard page */
                     33: int nCurPageNo = -1;           /* The current wizard page */
                     34: char WizardDestInstallPath [TC_MAX_PATH];
                     35: char WizardDestExtractPath [TC_MAX_PATH];
                     36: char SelfFile [TC_MAX_PATH];
                     37: 
                     38: HBITMAP hbmWizardBitmapRescaled = NULL;
                     39: 
                     40: BOOL bExtractOnly = FALSE;
                     41: BOOL bLicenseAccepted = FALSE;
                     42: BOOL bOpenContainingFolder = TRUE;
                     43: BOOL bExtractionSuccessful = FALSE;
                     44: BOOL bStartInstall = FALSE;
                     45: BOOL bStartExtraction = FALSE;
                     46: BOOL bInProgress = FALSE;
                     47: 
                     48: int nPbar = 0;                 /* Control ID of progress bar */
                     49: 
1.1.1.3   root       50: void localcleanupwiz (void)
1.1       root       51: {
                     52:        /* Delete buffered bitmaps (if any) */
                     53:        if (hbmWizardBitmapRescaled != NULL)
                     54:        {
                     55:                DeleteObject ((HGDIOBJ) hbmWizardBitmapRescaled);
                     56:                hbmWizardBitmapRescaled = NULL;
                     57:        }
                     58: }
                     59: 
                     60: static void InitWizardDestInstallPath (void)
                     61: {
                     62: 
                     63:        if (strlen (WizardDestInstallPath) < 2)
                     64:        {
                     65:                strcpy (WizardDestInstallPath, InstallationPath);
                     66:                if (WizardDestInstallPath [strlen (WizardDestInstallPath) - 1] != '\\')
                     67:                {
                     68:                        strcat (WizardDestInstallPath, "\\");
                     69:                }
                     70:        }
                     71: }
                     72: 
                     73: void LoadPage (HWND hwndDlg, int nPageNo)
                     74: {
                     75:        RECT rD, rW;
                     76: 
                     77:        if (hCurPage != NULL)
                     78:        {
                     79:                DestroyWindow (hCurPage);
                     80:        }
                     81: 
                     82:        GetWindowRect (GetDlgItem (hwndDlg, IDC_POS_BOX), &rW);
                     83: 
                     84:        nCurPageNo = nPageNo;
                     85: 
                     86:        switch (nPageNo)
                     87:        {
                     88:        case INTRO_PAGE:
                     89:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INTRO_PAGE_DLG), hwndDlg,
                     90:                                         (DLGPROC) PageDialogProc);
                     91:                break;
                     92: 
                     93:        case WIZARD_MODE_PAGE:
                     94:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_WIZARD_MODE_PAGE_DLG), hwndDlg,
                     95:                                         (DLGPROC) PageDialogProc);
                     96:                break;
                     97: 
                     98:        case INSTALL_OPTIONS_PAGE:
                     99:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INSTALL_OPTIONS_PAGE_DLG), hwndDlg,
                    100:                                         (DLGPROC) PageDialogProc);
                    101:                break;
                    102: 
                    103:        case INSTALL_PROGRESS_PAGE:
                    104:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PROGRESS_PAGE_DLG), hwndDlg,
                    105:                                         (DLGPROC) PageDialogProc);
                    106:                break;
                    107: 
                    108:        case EXTRACTION_OPTIONS_PAGE:
                    109:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_EXTRACTION_OPTIONS_PAGE_DLG), hwndDlg,
                    110:                                         (DLGPROC) PageDialogProc);
                    111:                break;
                    112: 
                    113:        case EXTRACTION_PROGRESS_PAGE:
                    114:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PROGRESS_PAGE_DLG), hwndDlg,
                    115:                                         (DLGPROC) PageDialogProc);
                    116:                break;
                    117:        }
                    118: 
                    119:        rD.left = 15;
                    120:        rD.top = 45;
                    121:        rD.right = 0;
                    122:        rD.bottom = 0;
                    123:        MapDialogRect (hwndDlg, &rD);
                    124: 
                    125:        if (hCurPage != NULL)
                    126:        {
                    127:                MoveWindow (hCurPage, rD.left, rD.top, rW.right - rW.left, rW.bottom - rW.top, TRUE);
                    128:                ShowWindow (hCurPage, SW_SHOWNORMAL);
                    129:        }
                    130: 
                    131:        /* Refresh the graphics (white background of some texts, etc.) */
                    132:        RefreshUIGFX ();
                    133: }
                    134: 
                    135: 
                    136: /* Except in response to the WM_INITDIALOG message, the dialog box procedure
                    137:    should return nonzero if it processes the message, and zero if it does
                    138:    not. - see DialogProc */
                    139: BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
                    140: {
                    141:        static char PageDebugId[128];
                    142:        WORD lw = LOWORD (wParam);
                    143:        WORD hw = HIWORD (wParam);
                    144: 
                    145:        hCurPage = hwndDlg;
                    146: 
                    147:        switch (uMsg)
                    148:        {
                    149:        case WM_INITDIALOG:
                    150:                LocalizeDialog (hwndDlg, "IDD_INSTL_DLG");
                    151: 
                    152:                sprintf (PageDebugId, "SETUP_WIZARD_PAGE_%d", nCurPageNo);
                    153:                LastDialogId = PageDebugId;
                    154: 
                    155:                switch (nCurPageNo)
                    156:                {
                    157:                case INTRO_PAGE:
                    158:                        {
                    159:                                char *licenseText = NULL;
                    160: 
                    161:                                licenseText = GetLegalNotices ();
                    162:                                if (licenseText != NULL)
                    163:                                {
                    164:                                        SetWindowText (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), licenseText);
                    165:                                        free (licenseText);
                    166:                                }
                    167:                                else
                    168:                                {
                    169:                                        Error("CANNOT_DISPLAY_LICENSE");
1.1.1.5   root      170:                                        exit (1);
1.1       root      171:                                }
                    172: 
                    173:                                /* Some of the following texts cannot be localized by third parties for legal reasons. */
                    174: 
1.1.1.5   root      175:                                SetCheckBox (hwndDlg, IDC_AGREE, bLicenseAccepted);
1.1       root      176: 
1.1.1.2   root      177:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), L"License");
                    178:                                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.5   root      179:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), L"IMPORTANT: By checking the checkbox below and clicking Accept, you accept these license terms and agree to be bound by and to comply with them. Click the 'arrow down' icon to see the rest of the license.");
1.1       root      180:                                //SendMessage (GetDlgItem (hwndDlg, IDC_BOX_HELP), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
                    181: 
1.1.1.2   root      182:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_AGREE), L"I a&ccept and agree to be bound by the license terms");
1.1.1.5   root      183:                                //SetWindowTextW (GetDlgItem (hwndDlg, IDC_DISAGREE), L"I &do not accept the license terms");
1.1       root      184: 
                    185:                                //SendMessage (GetDlgItem (hwndDlg, IDC_AGREE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
                    186:                                //SendMessage (GetDlgItem (hwndDlg, IDC_DISAGREE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
                    187: 
                    188:                                EnableWindow (GetDlgItem (hwndDlg, IDC_AGREE), TRUE);
                    189: 
                    190:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), L"&Accept");        // Cannot be localized by third parties for legal reasons.
                    191:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
                    192:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
                    193: 
                    194:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), bLicenseAccepted);
                    195:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
                    196:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), bLicenseAccepted);
1.1.1.5   root      197: 
                    198:                                // Left margin for license text
                    199:                                SendMessage (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), EM_SETMARGINS, (WPARAM) EC_LEFTMARGIN, (LPARAM) CompensateXDPI (4));
1.1       root      200:                        }
                    201:                        return 1;
                    202: 
                    203:                case WIZARD_MODE_PAGE:
                    204:                        {
1.1.1.8 ! root      205:                                LONG driverVersion;
1.1       root      206: 
1.1.1.8 ! root      207:                                DetermineUpgradeDowngradeStatus (TRUE, &driverVersion);
1.1       root      208: 
1.1.1.8 ! root      209:                                if (bRepairMode)
        !           210:                                {
        !           211:                                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), GetString ("REPAIR_REINSTALL"));
        !           212:                                        bExtractOnly = FALSE;
        !           213:                                }
        !           214:                                else if (bUpgrade)
        !           215:                                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), GetString ("UPGRADE"));
1.1       root      216: 
1.1.1.8 ! root      217:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_MODE_TITLE"));
        !           218:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_MODE_INFO"));
1.1       root      219: 
1.1.1.8 ! root      220:                                SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
        !           221:                                SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
1.1       root      222: 
1.1.1.8 ! root      223:                                CheckButton (GetDlgItem (hwndDlg, bExtractOnly ? IDC_WIZARD_MODE_EXTRACT_ONLY : IDC_WIZARD_MODE_INSTALL));
1.1       root      224: 
1.1.1.8 ! root      225:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SETUP_MODE_HELP_EXTRACT"));
1.1       root      226: 
1.1.1.8 ! root      227:                                if (!bRepairMode)
        !           228:                                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP2), GetString (bUpgrade ? "SETUP_MODE_HELP_UPGRADE" : "SETUP_MODE_HELP_INSTALL"));
        !           229: 
        !           230:                                EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), !bRepairMode);
        !           231:                                EnableWindow (GetDlgItem (hwndDlg, IDC_BOX_HELP), !bRepairMode);
        !           232:                                EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), TRUE);
1.1       root      233: 
1.1.1.8 ! root      234:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
        !           235:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
        !           236:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
        !           237:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
        !           238:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
        !           239:                        }
1.1       root      240:                        return 1;
                    241: 
                    242:                case EXTRACTION_OPTIONS_PAGE:
                    243: 
                    244:                        if (strlen(WizardDestExtractPath) < 2)
                    245:                        { 
                    246:                                strcpy (WizardDestExtractPath, SetupFilesDir);
                    247:                                strncat (WizardDestExtractPath, "TrueCrypt\\", sizeof (WizardDestExtractPath) - strlen (WizardDestExtractPath) - 1);
                    248:                        }
                    249: 
                    250:                        SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
                    251: 
                    252:                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
                    253: 
                    254:                        SetCheckBox (hwndDlg, IDC_OPEN_CONTAINING_FOLDER, bOpenContainingFolder);
                    255: 
                    256:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTION_OPTIONS_TITLE"));
                    257:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_OPTIONS_INFO"));
                    258:                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
                    259: 
                    260:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("EXTRACT"));
                    261:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
                    262:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
                    263:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
                    264:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
                    265: 
                    266:                        return 1;
                    267: 
                    268:                case EXTRACTION_PROGRESS_PAGE:
                    269: 
                    270:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTING_VERB"));
                    271:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_PROGRESS_INFO"));
                    272:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
                    273: 
                    274:                        if (bStartExtraction)
                    275:                        {
                    276:                                /* Start extraction */
                    277: 
                    278:                                LastDialogId = "EXTRACTION_IN_PROGRESS";
                    279: 
                    280:                                WaitCursor ();
                    281: 
                    282:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
                    283:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
                    284:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
                    285:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
                    286: 
                    287:                                if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
                    288:                                        strcat (WizardDestExtractPath, "\\");
                    289: 
                    290:                                strcpy (DestExtractPath, WizardDestExtractPath);
                    291: 
                    292:                                InitProgressBar ();
                    293: 
                    294:                                bInProgress = TRUE;
                    295:                                bStartExtraction = FALSE;
                    296: 
1.1.1.5   root      297:                                _beginthread (ExtractAllFilesThread, 0, (void *) hwndDlg);
1.1       root      298:                        }
                    299:                        else
                    300:                        {
                    301:                                NormalCursor ();
                    302: 
                    303:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
                    304:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
                    305:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
                    306:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
                    307:                        }
                    308: 
                    309:                        return 1;
                    310: 
                    311:                case INSTALL_OPTIONS_PAGE:
1.1.1.8 ! root      312:                        {
        !           313:                                LONG driverVersion;
1.1       root      314: 
1.1.1.8 ! root      315:                                DetermineUpgradeDowngradeStatus (TRUE, &driverVersion);
1.1       root      316: 
1.1.1.8 ! root      317:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_OPTIONS_TITLE"));
        !           318:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_OPTIONS_INFO"));
        !           319:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
1.1       root      320: 
1.1.1.8 ! root      321:                                InitWizardDestInstallPath ();
1.1       root      322: 
1.1.1.8 ! root      323:                                SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
1.1       root      324: 
1.1.1.8 ! root      325:                                SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
        !           326: 
        !           327:                                // System Restore
        !           328:                                SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, bSystemRestore);
        !           329:                                if (SystemRestoreDll == 0)
        !           330:                                {
        !           331:                                        SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, FALSE);
        !           332:                                        EnableWindow (GetDlgItem (hwndDlg, IDC_SYSTEM_RESTORE), FALSE);
        !           333:                                }
1.1       root      334: 
1.1.1.5   root      335: #if 0
1.1.1.8 ! root      336:                                // Swap files
        !           337:                                SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, bDisableSwapFiles);
        !           338:                                if (nCurrentOS == WIN_2000)
        !           339:                                {
        !           340:                                        bDisableSwapFiles = FALSE;
        !           341:                                        SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, FALSE);
        !           342:                                        EnableWindow (GetDlgItem (hwndDlg, IDC_DISABLE_PAGING_FILES), FALSE);
        !           343:                                }
1.1.1.5   root      344: #endif // 0
1.1.1.3   root      345: 
1.1.1.8 ! root      346:                                SetCheckBox (hwndDlg, IDC_ALL_USERS, bForAllUsers);
        !           347:                                SetCheckBox (hwndDlg, IDC_FILE_TYPE, bRegisterFileExt);
        !           348:                                SetCheckBox (hwndDlg, IDC_PROG_GROUP, bAddToStartMenu);
        !           349:                                SetCheckBox (hwndDlg, IDC_DESKTOP_ICON, bDesktopIcon);
1.1       root      350: 
1.1.1.8 ! root      351:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString (bUpgrade ? "UPGRADE" : "INSTALL"));
        !           352:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
1.1       root      353: 
1.1.1.8 ! root      354:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
        !           355:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
        !           356:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
        !           357:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
        !           358:                        }
1.1       root      359:                        return 1;
                    360: 
                    361:                case INSTALL_PROGRESS_PAGE:
                    362: 
                    363:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_PROGRESS_TITLE"));
                    364:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_PROGRESS_INFO"));
                    365:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
                    366:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
                    367: 
                    368:                        if (bStartInstall)
                    369:                        {
                    370:                                /* Start install */
                    371: 
                    372:                                LastDialogId = "INSTALL_IN_PROGRESS";
                    373: 
                    374:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
                    375: 
                    376:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
                    377:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
                    378:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
                    379:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
                    380: 
                    381:                                InitProgressBar ();
                    382: 
                    383:                                if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
                    384:                                        strcat (WizardDestInstallPath, "\\");
                    385: 
                    386:                                strcpy (InstallationPath, WizardDestInstallPath);
                    387: 
                    388:                                WaitCursor ();
                    389: 
                    390:                                bInProgress = TRUE;
                    391:                                bStartInstall = FALSE;
                    392: 
1.1.1.5   root      393:                                _beginthread (DoInstall, 0, (void *) hwndDlg);
1.1       root      394:                        }
                    395:                        else
                    396:                        {
                    397:                                NormalCursor ();
                    398: 
                    399:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
                    400:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
                    401:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
                    402:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
                    403: 
                    404:                        }
                    405: 
                    406:                        return 1;
                    407: 
                    408:                }
                    409:                return 0;
                    410: 
                    411:        case WM_HELP:
                    412:                if (bLicenseAccepted)
                    413:                        OpenPageHelp (GetParent (hwndDlg), nCurPageNo);
                    414: 
                    415:                return 1;
                    416: 
1.1.1.3   root      417:        case WM_ENDSESSION:
                    418:                EndDialog (MainDlg, 0);
                    419:                localcleanup ();
                    420:                return 0;
                    421: 
1.1       root      422: 
                    423:        case WM_COMMAND:
                    424: 
                    425:                if (lw == IDC_AGREE && nCurPageNo == INTRO_PAGE)
                    426:                {
1.1.1.5   root      427:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), IsButtonChecked (GetDlgItem (hwndDlg, IDC_AGREE)));
1.1       root      428:                        return 1;
                    429:                }
                    430: 
                    431:                if (lw == IDC_WIZARD_MODE_EXTRACT_ONLY && nCurPageNo == WIZARD_MODE_PAGE)
                    432:                {
                    433:                        bExtractOnly = TRUE;
                    434:                        return 1;
                    435:                }
                    436: 
                    437:                if (lw == IDC_WIZARD_MODE_INSTALL && nCurPageNo == WIZARD_MODE_PAGE)
                    438:                {
                    439:                        bExtractOnly = FALSE;
                    440:                        return 1;
                    441:                }
                    442: 
                    443:                if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE && hw == EN_CHANGE )
                    444:                {
                    445:                        EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
                    446:                        return 1;
                    447:                }
                    448: 
                    449:                if ( nCurPageNo == INSTALL_OPTIONS_PAGE && hw == EN_CHANGE )
                    450:                {
                    451:                        EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
                    452:                        return 1;
                    453:                }
                    454: 
                    455:                if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE )
                    456:                {
                    457:                        switch (lw)
                    458:                        {
                    459:                        case IDC_BROWSE:
                    460:                                if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestExtractPath))
                    461:                                {
                    462:                                        if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
                    463:                                        {
                    464:                                                strcat (WizardDestExtractPath, "\\");
                    465:                                        }
                    466:                                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
                    467:                                }
                    468:                                return 1;
                    469: 
                    470:                        case IDC_OPEN_CONTAINING_FOLDER:
1.1.1.2   root      471:                                bOpenContainingFolder = IsButtonChecked (GetDlgItem (hCurPage, IDC_OPEN_CONTAINING_FOLDER));
1.1       root      472:                                return 1;
                    473:                        }
                    474:                }
                    475: 
                    476:                if ( nCurPageNo == INSTALL_OPTIONS_PAGE )
                    477:                {
                    478:                        switch (lw)
                    479:                        {
                    480:                        case IDC_BROWSE:
                    481:                                if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestInstallPath))
                    482:                                {
                    483:                                        if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
                    484:                                        {
                    485:                                                strcat (WizardDestInstallPath, "\\");
                    486:                                        }
                    487:                                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
                    488:                                }
                    489:                                return 1;
                    490: 
                    491:                        case IDC_SYSTEM_RESTORE:
                    492:                                bSystemRestore = IsButtonChecked (GetDlgItem (hCurPage, IDC_SYSTEM_RESTORE));
                    493:                                return 1;
                    494: 
1.1.1.5   root      495: #if 0
1.1.1.3   root      496:                        case IDC_DISABLE_PAGING_FILES:
                    497: 
                    498:                                bDisableSwapFiles = IsButtonChecked (GetDlgItem (hCurPage, IDC_DISABLE_PAGING_FILES));
                    499: 
                    500:                                if (!bDisableSwapFiles
                    501:                                        && AskWarnNoYes("CONFIRM_NOT_DISABLING_SWAP_FILES") == IDNO)
                    502:                                {
                    503:                                        bDisableSwapFiles = TRUE;
                    504:                                        SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, bDisableSwapFiles);
                    505:                                }
                    506: 
                    507:                                return 1;
1.1.1.5   root      508: #endif // 0
1.1.1.3   root      509: 
1.1       root      510:                        case IDC_ALL_USERS:
                    511:                                bForAllUsers = IsButtonChecked (GetDlgItem (hCurPage, IDC_ALL_USERS));
                    512:                                return 1;
                    513: 
                    514:                        case IDC_FILE_TYPE:
                    515:                                bRegisterFileExt = IsButtonChecked (GetDlgItem (hCurPage, IDC_FILE_TYPE));
                    516:                                return 1;
                    517: 
                    518:                        case IDC_PROG_GROUP:
                    519:                                bAddToStartMenu = IsButtonChecked (GetDlgItem (hCurPage, IDC_PROG_GROUP));
                    520:                                return 1;
                    521: 
                    522:                        case IDC_DESKTOP_ICON:
                    523:                                bDesktopIcon = IsButtonChecked (GetDlgItem (hCurPage, IDC_DESKTOP_ICON));
                    524:                                return 1;
                    525: 
                    526:                        }
                    527:                }
                    528: 
                    529:                return 0;
                    530:        }
                    531: 
                    532:        return 0;
                    533: }
                    534: 
                    535: void InitProgressBar (void)
                    536: {
                    537:        HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
                    538:        SendMessage (hProgressBar, PBM_SETRANGE32, 0, 100);
                    539:        SendMessage (hProgressBar, PBM_SETSTEP, 1, 0);
                    540:        InvalidateRect (hProgressBar, NULL, TRUE);
                    541: }
                    542: 
                    543: // Must always return TRUE
                    544: BOOL UpdateProgressBarProc (int nPercent)
                    545: {
                    546:        HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
                    547:        SendMessage (hProgressBar, PBM_SETPOS, (int) (100.0 * nPercent / 100), 0);
                    548:        InvalidateRect (hProgressBar, NULL, TRUE);
                    549:        ShowWindow(hProgressBar, SW_HIDE);
                    550:        ShowWindow(hProgressBar, SW_SHOW);
                    551:        // Prevent the IDC_LOG_WINDOW item from partially disappearing at higher DPIs
                    552:        ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_HIDE);
                    553:        ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_SHOW);
                    554:        RefreshUIGFX();
                    555:        return TRUE;
                    556: }
                    557: 
                    558: void RefreshUIGFX (void)
                    559: {
                    560:        InvalidateRect (GetDlgItem (MainDlg, IDC_SETUP_WIZARD_BKG), NULL, TRUE);
                    561:        InvalidateRect (GetDlgItem (MainDlg, IDC_BOX_TITLE), NULL, TRUE);
                    562:        InvalidateRect (GetDlgItem (MainDlg, IDC_BOX_INFO), NULL, TRUE);
                    563:        InvalidateRect (GetDlgItem (MainDlg, IDC_BITMAP_SETUP_WIZARD), NULL, TRUE);
                    564:        InvalidateRect (GetDlgItem (MainDlg, IDC_HR), NULL, TRUE);
                    565:        // Prevent these items from disappearing at higher DPIs
                    566:        ShowWindow(GetDlgItem(MainDlg, IDC_HR), SW_HIDE);
                    567:        ShowWindow(GetDlgItem(MainDlg, IDC_HR), SW_SHOW);
                    568:        ShowWindow(GetDlgItem(MainDlg, IDC_HR_BOTTOM), SW_HIDE);
                    569:        ShowWindow(GetDlgItem(MainDlg, IDC_HR_BOTTOM), SW_SHOW);
                    570:        ShowWindow(GetDlgItem(MainDlg, IDC_BOX_INFO), SW_HIDE);
                    571:        ShowWindow(GetDlgItem(MainDlg, IDC_BOX_INFO), SW_SHOW);
                    572:        ShowWindow(GetDlgItem(MainDlg, IDC_BOX_TITLE), SW_HIDE);
                    573:        ShowWindow(GetDlgItem(MainDlg, IDC_BOX_TITLE), SW_SHOW);
                    574: }
                    575: 
                    576: 
                    577: /* Except in response to the WM_INITDIALOG message, the dialog box procedure
                    578:    should return nonzero if it processes the message, and zero if it does
                    579:    not. - see DialogProc */
                    580: BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
                    581: {
                    582:        WORD lw = LOWORD (wParam);
                    583: 
                    584:        switch (uMsg)
                    585:        {
                    586:        case WM_INITDIALOG:
                    587:                {
                    588:                        RECT rec;
                    589: 
                    590:                        GetModuleFileName (NULL, SelfFile, sizeof (SelfFile));
                    591: 
                    592:                        MainDlg = hwndDlg;
1.1.1.3   root      593: 
                    594:                        if (!CreateAppSetupMutex ())
                    595:                                AbortProcess ("TC_INSTALLER_IS_RUNNING");
                    596: 
1.1       root      597:                        InitDialog (hwndDlg);
                    598:                        LocalizeDialog (hwndDlg, "IDD_INSTL_DLG");
                    599:                        
                    600:                        // Resize the bitmap if the user has a non-default DPI 
                    601:                        if (ScreenDPI != USER_DEFAULT_SCREEN_DPI)
                    602:                        {
                    603:                                hbmWizardBitmapRescaled = RenderBitmap (MAKEINTRESOURCE (IDB_SETUP_WIZARD),
                    604:                                        GetDlgItem (hwndDlg, IDC_BITMAP_SETUP_WIZARD),
                    605:                                        0, 0, 0, 0, FALSE, TRUE);
                    606:                        }
                    607: 
                    608:                        // Gfx area background (must not keep aspect ratio; must retain Windows-imposed distortion)
                    609:                        GetClientRect (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_GFX_AREA), &rec);
                    610:                        SetWindowPos (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_BKG), HWND_TOP, 0, 0, rec.right, rec.bottom, SWP_NOMOVE);
                    611: 
                    612:                        nPbar = IDC_PROGRESS_BAR;
                    613: 
                    614:                        SendMessage (GetDlgItem (hwndDlg, IDC_BOX_TITLE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
                    615: 
1.1.1.6   root      616:                        SetWindowText (hwndDlg, "TrueCrypt Setup " VERSION_STRING);
1.1       root      617: 
                    618:                        if (bDevm)
                    619:                        {
                    620:                                InitWizardDestInstallPath ();
                    621:                                bSystemRestore = FALSE;
                    622:                                bRegisterFileExt = FALSE;
                    623:                                bAddToStartMenu = FALSE;
                    624:                                bDesktopIcon = TRUE;
                    625:                                bLicenseAccepted = TRUE;
                    626:                                bStartInstall = TRUE;
                    627:                                LoadPage (hwndDlg, INSTALL_PROGRESS_PAGE);
                    628:                        }
                    629:                        else
                    630:                                LoadPage (hwndDlg, INTRO_PAGE);
1.1.1.3   root      631: 
1.1       root      632:                }
                    633:                return 0;
                    634: 
                    635:        case WM_SYSCOMMAND:
                    636:                if (lw == IDC_ABOUT)
                    637:                {
                    638:                        if (bLicenseAccepted)
                    639:                                DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc);
                    640: 
                    641:                        return 1;
                    642:                }
                    643:                return 0;
                    644: 
                    645:        case WM_HELP:
                    646:                if (bLicenseAccepted)
                    647:                        OpenPageHelp (hwndDlg, nCurPageNo);
                    648: 
                    649:                return 1;
                    650: 
                    651:        case WM_COMMAND:
                    652:                if (lw == IDHELP)
                    653:                {
                    654:                        if (bLicenseAccepted)
                    655:                                OpenPageHelp (hwndDlg, nCurPageNo);
                    656: 
                    657:                        return 1;
                    658:                }
                    659:                if (lw == IDCANCEL)
                    660:                {
                    661:                        PostMessage (hwndDlg, WM_CLOSE, 0, 0);
                    662:                        return 1;
                    663:                }
                    664:                if (lw == IDC_NEXT)
                    665:                {
                    666:                        if (nCurPageNo == INTRO_PAGE)
                    667:                        {
                    668:                                if (!IsButtonChecked (GetDlgItem (hCurPage, IDC_AGREE)))
                    669:                                {
                    670:                                        bLicenseAccepted = FALSE;
                    671:                                        return 1;
                    672:                                }
                    673:                                bLicenseAccepted = TRUE;
                    674:                                EnableWindow (GetDlgItem (hwndDlg, IDHELP), TRUE);
1.1.1.8 ! root      675: 
        !           676:                                if (nCurrentOS == WIN_2000)
        !           677:                                        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 will stop 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       root      678:                        }
                    679: 
                    680:                        else if (nCurPageNo == WIZARD_MODE_PAGE)
                    681:                        {
1.1.1.5   root      682:                                if (IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY)))
1.1       root      683:                                {
1.1.1.5   root      684:                                        if (IsUacSupported() 
                    685:                                                && AskWarnYesNo ("TRAVELER_UAC_NOTE") == IDNO)
                    686:                                        {
                    687:                                                return 1;
                    688:                                        }
                    689: 
                    690:                                        bExtractOnly = TRUE;
1.1       root      691:                                        nCurPageNo = EXTRACTION_OPTIONS_PAGE - 1;
                    692:                                }
                    693:                        }
                    694: 
                    695:                        else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
                    696:                        {
                    697:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
                    698:                                bStartExtraction = TRUE;
                    699:                        }
                    700:                        
                    701:                        else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
                    702:                        {
                    703:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
                    704:                                bStartInstall = TRUE;
                    705:                        }
                    706: 
                    707:                        else if (nCurPageNo == INSTALL_PROGRESS_PAGE)
                    708:                        {
                    709:                                PostMessage (hwndDlg, WM_CLOSE, 0, 0);
                    710:                                return 1;
                    711:                        }
                    712: 
                    713:                        else if (nCurPageNo == EXTRACTION_PROGRESS_PAGE)
                    714:                        {
                    715:                                PostMessage (hwndDlg, WM_CLOSE, 0, 0);
                    716:                                return 1;
                    717:                        }
                    718: 
                    719:                        LoadPage (hwndDlg, ++nCurPageNo);
                    720: 
                    721:                        return 1;
                    722:                }
                    723: 
                    724:                if (lw == IDC_PREV)
                    725:                {
                    726:                        if (nCurPageNo == WIZARD_MODE_PAGE)
                    727:                        {
                    728:                                bExtractOnly = IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY));
                    729:                        }
                    730: 
                    731:                        else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
                    732:                        {
                    733:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
                    734:                                nCurPageNo = WIZARD_MODE_PAGE + 1;
                    735:                        }
                    736: 
                    737:                        else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
                    738:                        {
                    739:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
                    740:                        }
                    741: 
                    742:                        LoadPage (hwndDlg, --nCurPageNo);
                    743: 
                    744:                        return 1;
                    745:                }
                    746: 
                    747:                return 0;
                    748: 
                    749:        case WM_CTLCOLORSTATIC:
                    750: 
                    751:                /* This maintains the white background under the transparent-backround texts */
                    752: 
                    753:                SetBkMode ((HDC) wParam, TRANSPARENT);
                    754:                return ((LONG) (HBRUSH) (GetStockObject (NULL_BRUSH)));
                    755: 
                    756:        case WM_ERASEBKGND:
                    757:                return 0;
                    758: 
                    759:        case TC_APPMSG_INSTALL_SUCCESS:
                    760:                
                    761:                /* Installation completed successfully */
                    762:                
                    763:                bInProgress = FALSE;
                    764: 
                    765:                NormalCursor ();
                    766: 
1.1.1.8 ! root      767:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
1.1       root      768:                EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
                    769:                EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
                    770:                EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
                    771:                EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
                    772: 
                    773:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("SETUP_FINISHED_TITLE"));
1.1.1.5   root      774:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString (bRestartRequired ? "SETUP_FINISHED_INFO_RESTART_REQUIRED" : "SETUP_FINISHED_INFO"));
1.1       root      775: 
                    776:                RefreshUIGFX ();
                    777:                return 1;
                    778: 
                    779:        case TC_APPMSG_INSTALL_FAILURE:
                    780:                
                    781:                /* Extraction failed */
                    782:                
                    783:                bInProgress = FALSE;
                    784: 
                    785:                NormalCursor ();
                    786: 
                    787:                nCurPageNo = INSTALL_OPTIONS_PAGE;
                    788:                LoadPage (hwndDlg, nCurPageNo);
                    789:                return 1;
                    790: 
                    791:        case TC_APPMSG_EXTRACTION_SUCCESS:
                    792:                
                    793:                /* Extraction completed successfully */
                    794: 
                    795:                InvalidateRect (GetDlgItem (MainDlg, IDD_INSTL_DLG), NULL, TRUE);
                    796: 
                    797:                bInProgress = FALSE;
                    798:                bExtractionSuccessful = TRUE;
                    799: 
                    800:                NormalCursor ();
                    801: 
                    802:                StatusMessage (hCurPage, "EXTRACTION_FINISHED_INFO");
                    803: 
                    804:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
                    805:                EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
                    806:                EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
                    807:                EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
                    808:                EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
                    809: 
                    810:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("EXTRACTION_FINISHED_TITLE"));
                    811:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString ("EXTRACTION_FINISHED_INFO"));
                    812: 
                    813:                RefreshUIGFX ();
                    814:                UpdateProgressBarProc(100);
                    815: 
                    816:                Info ("EXTRACTION_FINISHED_INFO");
                    817: 
                    818:                return 1;
                    819: 
                    820:        case TC_APPMSG_EXTRACTION_FAILURE:
                    821:                
                    822:                /* Extraction failed */
                    823:                
                    824:                bInProgress = FALSE;
                    825: 
                    826:                NormalCursor ();
                    827: 
                    828:                StatusMessage (hCurPage, "EXTRACTION_FAILED");
                    829: 
                    830:                UpdateProgressBarProc(0);
                    831: 
                    832:                Error ("EXTRACTION_FAILED");
                    833: 
                    834:                nCurPageNo = EXTRACTION_OPTIONS_PAGE;
                    835:                LoadPage (hwndDlg, nCurPageNo);
                    836:                return 1;
                    837: 
                    838:        case WM_CLOSE:
1.1.1.3   root      839: 
1.1       root      840:                if (bInProgress)
                    841:                {
                    842:                        NormalCursor();
                    843:                        if (AskNoYes("CONFIRM_EXIT_UNIVERSAL") == IDNO)
                    844:                        {
                    845:                                return 1;
                    846:                        }
                    847:                        WaitCursor ();
                    848:                }
                    849: 
                    850:                if (bOpenContainingFolder && bExtractOnly && bExtractionSuccessful)
                    851:                        ShellExecute (NULL, "open", WizardDestExtractPath, NULL, NULL, SW_SHOWNORMAL);
                    852: 
                    853:                EndDialog (hwndDlg, IDCANCEL);
                    854:                return 1;
                    855:        }
                    856: 
                    857:        return 0;
                    858: }
                    859: 
                    860: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.