"Fossies" - the Fresh Open Source Software Archive

Member "src/Setup/Wizard.c" (10 Oct 2018, 35085 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Wizard.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.22_Source_vs_1.23_Source.

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