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

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

unix.superglobalmegacorp.com

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