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

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

unix.superglobalmegacorp.com

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