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

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

unix.superglobalmegacorp.com

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