"Fossies" - the Fresh Open Source Software Archive

Member "src/Common/Dlgcode.h" (10 Oct 2018, 29853 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 "Dlgcode.h" 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 #ifndef TC_HEADER_DLGCODE
   15 #define TC_HEADER_DLGCODE
   16 
   17 #include "Common.h"
   18 #include "Apidrvr.h"
   19 #include "Keyfiles.h"
   20 #include "Wipe.h"
   21 
   22 #ifdef __cplusplus
   23 extern "C" {
   24 #endif
   25 
   26 /* IDs for dynamically generated GUI elements */
   27 enum dynamic_gui_element_ids
   28 {
   29     IDPM_CHECK_FILESYS = 500001,
   30     IDPM_REPAIR_FILESYS,
   31     IDPM_OPEN_VOLUME,
   32     IDPM_SELECT_FILE_AND_MOUNT,
   33     IDPM_SELECT_DEVICE_AND_MOUNT,
   34     IDPM_ADD_TO_FAVORITES,
   35     IDPM_ADD_TO_SYSTEM_FAVORITES,
   36     IDM_SHOW_HIDE,
   37     IDM_HOMEPAGE_SYSTRAY,
   38     IDPM_COPY_VALUE_TO_CLIPBOARD
   39 };
   40 
   41 enum
   42 {
   43     TC_TBXID_LEGAL_NOTICES,
   44     TC_TBXID_SYS_ENCRYPTION_PRETEST,
   45     TC_TBXID_SYS_ENC_RESCUE_DISK,
   46     TC_TBXID_DECOY_OS_INSTRUCTIONS,
   47     TC_TBXID_EXTRA_BOOT_PARTITION_REMOVAL_INSTRUCTIONS
   48 };
   49 
   50 #define TC_APPLICATION_ID   L"IDRIX.VeraCrypt"
   51 
   52 #define TC_MUTEX_NAME_SYSENC                L"Global\\VeraCrypt System Encryption Wizard"
   53 #define TC_MUTEX_NAME_NONSYS_INPLACE_ENC    L"Global\\VeraCrypt In-Place Encryption Wizard"
   54 #define TC_MUTEX_NAME_APP_SETUP             L"Global\\VeraCrypt Setup"
   55 #define TC_MUTEX_NAME_DRIVER_SETUP          L"Global\\VeraCrypt Driver Setup"
   56 
   57 #define IDC_ABOUT 0x7fff    /* ID for AboutBox on system menu in wm_user range */
   58 
   59 #define EXCL_ACCESS_MAX_AUTO_RETRIES 500
   60 #define EXCL_ACCESS_AUTO_RETRY_DELAY 10
   61 
   62 #define UNMOUNT_MAX_AUTO_RETRIES 30
   63 #define UNMOUNT_AUTO_RETRY_DELAY 50
   64 
   65 // After the user receives the "Incorrect password" error this number of times in a row, we should automatically
   66 // try using the embedded header backup (if any). This ensures that the "Incorrect password" message is reported faster
   67 // initially (most such errors are really caused by supplying an incorrect password, not by header corruption).
   68 #define TC_TRY_HEADER_BAK_AFTER_NBR_WRONG_PWD_TRIES     2
   69 
   70 #define MAX_MULTI_CHOICES       10      /* Maximum number of options for mutliple-choice dialog */
   71 
   72 #define TC_APPD_FILENAME_CONFIGURATION                      L"Configuration.xml"
   73 #define TC_APPD_FILENAME_SYSTEM_ENCRYPTION                  L"System Encryption.xml"
   74 #define TC_APPD_FILENAME_DEFAULT_KEYFILES                   L"Default Keyfiles.xml"
   75 #define TC_APPD_FILENAME_HISTORY                            L"History.xml"
   76 #define TC_APPD_FILENAME_FAVORITE_VOLUMES                   L"Favorite Volumes.xml"
   77 #define TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES            _T(TC_APP_NAME) L" System Favorite Volumes.xml"
   78 #define TC_APPD_FILENAME_NONSYS_INPLACE_ENC                 L"In-Place Encryption"
   79 #define TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE            L"In-Place Encryption Wipe Algo"
   80 #define TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL         L"Post-Install Task - Tutorial"
   81 #define TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES    L"Post-Install Task - Release Notes"
   82 #define TC_APPD_FILENAME_POST_INSTALL_TASK_RESCUE_DISK      L"Post-Install Task - Rescue Disk"
   83 
   84 #define VC_FILENAME_RENAMED_SUFFIX              L"_old"
   85 
   86 #ifndef USER_DEFAULT_SCREEN_DPI
   87 #define USER_DEFAULT_SCREEN_DPI 96
   88 #endif
   89 
   90 #if (USER_DEFAULT_SCREEN_DPI != 96)
   91 #   error Revision of GUI and graphics necessary, since everything assumes default screen DPI as 96 (note that 96 is the default on Windows 2000, XP, and Vista).
   92 #endif
   93 
   94 enum
   95 {
   96     TC_POST_INSTALL_CFG_REMOVE_ALL = 0,
   97     TC_POST_INSTALL_CFG_TUTORIAL,
   98     TC_POST_INSTALL_CFG_RELEASE_NOTES,
   99     TC_POST_INSTALL_CFG_RESCUE_DISK,
  100 };
  101 
  102 extern char *LastDialogId;
  103 extern char *ConfigBuffer;
  104 extern wchar_t szHelpFile[TC_MAX_PATH];
  105 extern wchar_t szHelpFile2[TC_MAX_PATH];
  106 extern wchar_t SecurityTokenLibraryPath[TC_MAX_PATH];
  107 extern char CmdTokenPin [TC_MAX_PATH];
  108 extern HFONT hFixedDigitFont;
  109 extern HFONT hBoldFont;
  110 extern HFONT hTitleFont;
  111 extern HFONT hFixedFont;
  112 extern HFONT hUserFont;
  113 extern HFONT hUserUnderlineFont;
  114 extern HFONT hUserBoldFont;
  115 extern HFONT WindowTitleBarFont;
  116 extern int ScreenDPI;
  117 extern double DlgAspectRatio;
  118 extern HWND MainDlg;
  119 extern BOOL Silent;
  120 extern BOOL bHistory;
  121 extern BOOL bPreserveTimestamp;
  122 extern BOOL bShowDisconnectedNetworkDrives;
  123 extern BOOL bHideWaitingDialog;
  124 extern BOOL bCmdHideWaitingDialog;
  125 extern BOOL bCmdHideWaitingDialogValid;
  126 extern BOOL bUseSecureDesktop;
  127 extern BOOL bCmdUseSecureDesktop;
  128 extern BOOL bCmdUseSecureDesktopValid;
  129 extern BOOL bStartOnLogon;
  130 extern BOOL bMountDevicesOnLogon;
  131 extern BOOL bMountFavoritesOnLogon;
  132 extern int HiddenSectorDetectionStatus;
  133 extern wchar_t *lpszTitle;
  134 extern OSVersionEnum nCurrentOS;
  135 extern int CurrentOSMajor;
  136 extern int CurrentOSMinor;
  137 extern int CurrentOSServicePack;
  138 extern int CurrentOSBuildNumber;
  139 extern BOOL RemoteSession;
  140 extern HANDLE hDriver;
  141 extern HINSTANCE hInst;
  142 extern int SystemEncryptionStatus;
  143 extern WipeAlgorithmId nWipeMode;
  144 extern BOOL bSysPartitionSelected;
  145 extern BOOL bSysDriveSelected;
  146 
  147 extern wchar_t SysPartitionDevicePath [TC_MAX_PATH];
  148 extern wchar_t SysDriveDevicePath [TC_MAX_PATH];
  149 extern char bCachedSysDevicePathsValid;
  150 
  151 extern BOOL bHyperLinkBeingTracked;
  152 extern BOOL bInPlaceEncNonSysPending;
  153 
  154 extern BOOL PimEnable;
  155 extern BOOL KeyFilesEnable;
  156 extern KeyFile  *FirstKeyFile;
  157 extern KeyFilesDlgParam     defaultKeyFilesParam;
  158 extern BOOL UacElevated;
  159 extern BOOL IgnoreWmDeviceChange;
  160 extern BOOL DeviceChangeBroadcastDisabled;
  161 extern BOOL LastMountedVolumeDirty;
  162 extern BOOL MountVolumesAsSystemFavorite;
  163 extern BOOL FavoriteMountOnArrivalInProgress;
  164 extern BOOL MultipleMountOperationInProgress;
  165 
  166 #ifndef SETUP
  167 extern BOOL bLanguageSetInSetup;
  168 #endif
  169 
  170 enum tc_app_msg_ids
  171 {
  172     /* WARNING: Changing these values or their meanings may cause incompatibility with other versions
  173     (for example, if a new version of the TrueCrypt installer needed to shut down this version of
  174     TrueCrypt during upgrade, it could fail or do something unwanted because the signal value would
  175     be incorrect). When adding a new constant, verify that the value is unique within this block and
  176     that it is less than WM_APP+16383. */
  177 
  178     // Common (inter-app)
  179     TC_APPMSG_CLOSE_BKG_TASK =                      WM_APP + 4, // Changing this value will prevent smooth upgrades from pre-5.x versions
  180     TC_APPMSG_SYSENC_CONFIG_UPDATE =                WM_APP + 101,
  181     TC_APPMSG_TASKBAR_ICON =                        WM_APP + 102,
  182     TC_APPMSG_LOAD_TEXT_BOX_CONTENT =               WM_APP + 103,
  183     // Mount
  184     TC_APPMSG_MOUNT_ENABLE_DISABLE_CONTROLS =       WM_APP + 201,
  185     TC_APPMSG_MOUNT_SHOW_WINDOW =                   WM_APP + 202,
  186     TC_APPMSG_PREBOOT_PASSWORD_MODE =               WM_APP + 203,
  187     VC_APPMSG_CREATE_RESCUE_DISK =                  WM_APP + 204,
  188     // Format
  189     TC_APPMSG_VOL_TRANSFORM_THREAD_ENDED =          WM_APP + 301,
  190     TC_APPMSG_FORMAT_FINISHED =                     WM_APP + 302,
  191     TC_APPMSG_FORMAT_USER_QUIT =                    WM_APP + 303,
  192     TC_APPMSG_PERFORM_POST_WMINIT_TASKS =           WM_APP + 304,
  193     TC_APPMSG_PERFORM_POST_SYSENC_WMINIT_TASKS =    WM_APP + 305,
  194     TC_APPMSG_NONSYS_INPLACE_ENC_FINISHED =         WM_APP + 306,
  195     // Setup
  196     TC_APPMSG_INSTALL_SUCCESS =                     WM_APP + 401,
  197     TC_APPMSG_UNINSTALL_SUCCESS =                   WM_APP + 402,
  198     TC_APPMSG_EXTRACTION_SUCCESS =                  WM_APP + 403,
  199     TC_APPMSG_INSTALL_FAILURE =                     WM_APP + 404,
  200     TC_APPMSG_UNINSTALL_FAILURE =                   WM_APP + 405,
  201     TC_APPMSG_EXTRACTION_FAILURE =                  WM_APP + 406
  202 };
  203 
  204 enum system_encryption_status
  205 {
  206     /* WARNING: As these values are written to config files, if they or their meanings
  207     are changed, incompatiblity with other versions may arise (upgrade, downgrade, etc.).
  208     When adding a new constant, verify that the value is unique within this block. */
  209     SYSENC_STATUS_NONE = 0,
  210     SYSENC_STATUS_PRETEST = 200,    // This may also mean that the OS is to be (or has been) copied to a hidden volume (to create a hidden OS).
  211     SYSENC_STATUS_ENCRYPTING = 400,
  212     SYSENC_STATUS_DECRYPTING = 600
  213 };
  214 
  215 enum vol_creation_wizard_modes
  216 {
  217     WIZARD_MODE_FILE_CONTAINER = 0,
  218     WIZARD_MODE_NONSYS_DEVICE,
  219     WIZARD_MODE_SYS_DEVICE
  220 };
  221 
  222 
  223 typedef struct
  224 {
  225     BOOL VolumeIsOpen;
  226 
  227     CRYPTO_INFO *CryptoInfo;
  228     BOOL IsDevice;
  229     HANDLE HostFileHandle;
  230     uint64 HostSize;
  231 
  232     BOOL TimestampsValid;
  233     FILETIME CreationTime;
  234     FILETIME LastWriteTime;
  235     FILETIME LastAccessTime;
  236 
  237 } OpenVolumeContext;
  238 
  239 
  240 #define DEFAULT_VOL_CREATION_WIZARD_MODE    WIZARD_MODE_FILE_CONTAINER
  241 
  242 #define ICON_HAND MB_ICONHAND
  243 #define YES_NO MB_YESNO
  244 
  245 #define ISO_BURNER_TOOL L"isoburn.exe"
  246 #define PRINT_TOOL L"notepad.exe"
  247 
  248 void InitGlobalLocks ();
  249 void FinalizeGlobalLocks ();
  250 void cleanup ( void );
  251 void LowerCaseCopy ( wchar_t *lpszDest , const wchar_t *lpszSource );
  252 void UpperCaseCopy ( wchar_t *lpszDest , size_t cbDest, const wchar_t *lpszSource );
  253 BOOL IsNullTerminateString (const wchar_t* str, size_t cbSize);
  254 void CreateFullVolumePath ( wchar_t *lpszDiskFile , size_t cbDiskFile, const wchar_t *lpszFileName , BOOL *bDevice );
  255 int FakeDosNameForDevice ( const wchar_t *lpszDiskFile , wchar_t *lpszDosDevice , size_t cbDosDevice, wchar_t *lpszCFDevice , size_t cbCFDevice, BOOL bNameOnly );
  256 int RemoveFakeDosName ( wchar_t *lpszDiskFile , wchar_t *lpszDosDevice );
  257 void AbortProcessDirect ( wchar_t *abortMsg );
  258 void AbortProcess ( char *stringId );
  259 void AbortProcessSilent ( void );
  260 void *err_malloc ( size_t size );
  261 char *err_strdup ( char *lpszText );
  262 DWORD handleWin32Error ( HWND hwndDlg, const char* srcPos );
  263 BOOL IsDiskReadError (DWORD error);
  264 BOOL IsDiskWriteError (DWORD error);
  265 BOOL IsDiskError (DWORD error);
  266 BOOL translateWin32Error ( wchar_t *lpszMsgBuf , int nWSizeOfBuf );
  267 BOOL CALLBACK AboutDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
  268 static BOOL CALLBACK StaticModelessWaitDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  269 void DisplayStaticModelessWaitDlg (HWND parent);
  270 void CloseStaticModelessWaitDlg (void);
  271 BOOL IsButtonChecked ( HWND hButton );
  272 void CheckButton ( HWND hButton );
  273 void LeftPadString (wchar_t *szTmp, int len, int targetLen, wchar_t filler);
  274 void InitDialog ( HWND hwndDlg );
  275 void ProcessPaintMessages (HWND hwnd, int maxMessagesToProcess);
  276 HDC CreateMemBitmap ( HINSTANCE hInstance , HWND hwnd , wchar_t *resource );
  277 HBITMAP RenderBitmap ( wchar_t *resource , HWND hwndDest , int x , int y , int nWidth , int nHeight , BOOL bDirectRender , BOOL bKeepAspectRatio);
  278 LRESULT CALLBACK RedTick ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );
  279 BOOL RegisterRedTick ( HINSTANCE hInstance );
  280 BOOL UnregisterRedTick ( HINSTANCE hInstance );
  281 LRESULT CALLBACK SplashDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );
  282 void WaitCursor ( void );
  283 void NormalCursor ( void );
  284 void ArrowWaitCursor ( void );
  285 void HandCursor ();
  286 void AddComboPair (HWND hComboBox, const wchar_t *lpszItem, int value);
  287 void SelectAlgo ( HWND hComboBox , int *nCipher );
  288 void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption, BOOL bHeaderWipe);
  289 wchar_t *GetWipeModeName (WipeAlgorithmId modeId);
  290 wchar_t *GetPathType (const wchar_t *path, BOOL bUpperCase, BOOL *bIsPartition);
  291 LRESULT CALLBACK CustomDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );
  292 BOOL TCCreateMutex (volatile HANDLE *hMutex, wchar_t *name);
  293 void TCCloseMutex (volatile HANDLE *hMutex);
  294 BOOL MutexExistsOnSystem (wchar_t *name);
  295 BOOL CreateSysEncMutex (void);
  296 BOOL InstanceHasSysEncMutex (void);
  297 void CloseSysEncMutex (void);
  298 BOOL CreateNonSysInplaceEncMutex (void);
  299 BOOL InstanceHasNonSysInplaceEncMutex (void);
  300 void CloseNonSysInplaceEncMutex (void);
  301 BOOL NonSysInplaceEncInProgressElsewhere (void);
  302 BOOL CreateDriverSetupMutex (void);
  303 void CloseDriverSetupMutex (void);
  304 BOOL CreateAppSetupMutex (void);
  305 BOOL InstanceHasAppSetupMutex (void);
  306 void CloseAppSetupMutex (void);
  307 BOOL IsTrueCryptInstallerRunning (void);
  308 uint32 ReadDriverConfigurationFlags ();
  309 uint32 ReadEncryptionThreadPoolFreeCpuCountLimit ();
  310 BOOL LoadSysEncSettings ();
  311 int LoadNonSysInPlaceEncSettings (WipeAlgorithmId *wipeAlgorithm);
  312 void RemoveNonSysInPlaceEncNotifications (void);
  313 void SavePostInstallTasksSettings (int command);
  314 void DoPostInstallTasks (HWND hwndDlg);
  315 void InitOSVersionInfo ();
  316 void InitApp ( HINSTANCE hInstance, wchar_t *lpszCommandLine );
  317 void FinalizeApp (void);
  318 void InitHelpFileName (void);
  319 BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem, BOOL computeVolumeID);
  320 void NotifyDriverOfPortableMode (void);
  321 int GetAvailableFixedDisks ( HWND hComboBox , char *lpszRootPath );
  322 int GetAvailableRemovables ( HWND hComboBox , char *lpszRootPath );
  323 int IsSystemDevicePath (const wchar_t *path, HWND hwndDlg, BOOL bReliableRequired);
  324 int IsNonSysPartitionOnSysDrive (const wchar_t *path);
  325 BOOL CALLBACK RawDevicesDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
  326 BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  327 INT_PTR TextInfoDialogBox (int nID);
  328 BOOL CALLBACK TextInfoDialogBoxDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  329 char * GetLegalNotices ();
  330 BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  331 void UserEnrichRandomPool (HWND hwndDlg);
  332 BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  333 BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  334 int DriverAttach ( void );
  335 BOOL CALLBACK CipherTestDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam );
  336 void ResetCipherTest ( HWND hwndDlg , int idTestCipher );
  337 void ResetCurrentDirectory ();
  338 BOOL BrowseFiles (HWND hwndDlg, char *stringId, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter);
  339 BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, wchar_t *dirName);
  340 void handleError ( HWND hwndDlg , int code, const char* srcPos );
  341 BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const wchar_t *fileName);
  342 void LocalizeDialog ( HWND hwnd, char *stringId );
  343 void OpenVolumeExplorerWindow (int driveNo);
  344 static BOOL CALLBACK CloseVolumeExplorerWindowsEnum( HWND hwnd, LPARAM driveNo);
  345 BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo);
  346 BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue);
  347 BOOL CheckCapsLock (HWND hwnd, BOOL quiet);
  348 BOOL CheckFileExtension (wchar_t *fileName);
  349 void CorrectFileName (wchar_t* fileName);
  350 void CorrectURL (wchar_t* fileName);
  351 void IncreaseWrongPwdRetryCount (int count);
  352 void ResetWrongPwdRetryCount (void);
  353 BOOL WrongPwdRetryCountOverLimit (void);
  354 DWORD GetUsedLogicalDrives (void);
  355 int GetFirstAvailableDrive ();
  356 int GetLastAvailableDrive ();
  357 BOOL IsDriveAvailable (int driveNo);
  358 BOOL IsDeviceMounted (wchar_t *deviceName);
  359 int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced);
  360 void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap);
  361 int MountVolume (HWND hwndDlg, int driveNo, wchar_t *volumePath, Password *password, int pkcs5, int pim, BOOL truecryptMode, BOOL cachePassword, BOOL cachePim, BOOL sharedAccess,  const MountOptions* const mountOptions, BOOL quiet, BOOL bReportWrongPassword);
  362 BOOL UnmountVolume (HWND hwndDlg , int nDosDriveNo, BOOL forceUnmount);
  363 BOOL UnmountVolumeAfterFormatExCall (HWND hwndDlg, int nDosDriveNo);
  364 BOOL IsPasswordCacheEmpty (void);
  365 BOOL IsMountedVolumeID (BYTE volumeID[VOLUME_ID_SIZE]);
  366 BOOL IsMountedVolume (const wchar_t *volname);
  367 int GetMountedVolumeDriveNo (wchar_t *volname);
  368 BOOL IsAdmin (void);
  369 BOOL IsBuiltInAdmin ();
  370 BOOL IsUacSupported ();
  371 BOOL ResolveSymbolicLink (const wchar_t *symLinkName, PWSTR targetName, size_t cbTargetName);
  372 int GetDiskDeviceDriveLetter (PWSTR deviceName);
  373 int FileSystemAppearsEmpty (const wchar_t *devicePath);
  374 __int64 GetStatsFreeSpaceOnPartition (const wchar_t *devicePath, float *percent, __int64 *occupiedBytes, BOOL silent);
  375 __int64 GetDeviceSize (const wchar_t *devicePath);
  376 HANDLE DismountDrive (wchar_t *devName, wchar_t *devicePath);
  377 int64 FindString (const char *buf, const char *str, int64 bufLen, int64 strLen, int64 startOffset);
  378 BOOL FileExists (const wchar_t *filePathPtr);
  379 __int64 FindStringInFile (const wchar_t *filePath, const char *str, int strLen);
  380 BOOL TCCopyFile (wchar_t *sourceFileName, wchar_t *destinationFile);
  381 BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile, DWORD inputLength, BOOL bAppend, BOOL bRenameIfFailed);
  382 typedef void (_cdecl *ProgressFn) ( HWND hwndDlg , const wchar_t *txt );
  383 BOOL DecompressZipToDir (const unsigned char *inputBuffer, DWORD inputLength, const wchar_t *destinationFile, ProgressFn progressFnPtr, HWND hwndDlg);
  384 BOOL TCFlushFile (FILE *f);
  385 BOOL PrintHardCopyTextUTF16 (wchar_t *text, wchar_t *title, size_t byteLen);
  386 void GetSpeedString (unsigned __int64 speed, wchar_t *str, size_t cbStr);
  387 BOOL IsNonInstallMode ();
  388 BOOL DriverUnload ();
  389 LRESULT SetCheckBox (HWND hwndDlg, int dlgItem, BOOL state);
  390 BOOL GetCheckBox (HWND hwndDlg, int dlgItem);
  391 void SetListScrollHPos (HWND hList, int topMostVisibleItem);
  392 void ManageStartupSeq (void);
  393 void ManageStartupSeqWiz (BOOL bRemove, const wchar_t *arg);
  394 void CleanLastVisitedMRU (void);
  395 void ClearHistory (HWND hwndDlgItem);
  396 LRESULT ListItemAdd (HWND list, int index, const wchar_t *string);
  397 LRESULT ListSubItemSet (HWND list, int index, int subIndex, const wchar_t *string);
  398 BOOL GetMountList (MOUNT_LIST_STRUCT *list);
  399 int GetDriverRefCount ();
  400 void GetSizeString (unsigned __int64 size, wchar_t *str, size_t cbStr);
  401 __int64 GetFileSize64 (const wchar_t *path);
  402 BOOL LoadInt16 (const wchar_t *filePath, int *result, __int64 fileOffset);
  403 BOOL LoadInt32 (const wchar_t *filePath, unsigned __int32 *result, __int64 fileOffset);
  404 char *LoadFile (const wchar_t *fileName, DWORD *size);
  405 char *LoadFileBlock (const wchar_t *fileName, __int64 fileOffset, DWORD count);
  406 wchar_t *GetModPath (wchar_t *path, int maxSize);
  407 wchar_t *GetConfigPath (wchar_t *fileName);
  408 wchar_t *GetProgramConfigPath (wchar_t *fileName);
  409 wchar_t GetSystemDriveLetter (void);
  410 void OpenPageHelp (HWND hwndDlg, int nPage);
  411 void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *text, BOOL warning);
  412 void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd);
  413 void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd);
  414 void WarningBalloon (char *headingStringId, char *textStringId, HWND hwnd);
  415 void WarningBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd);
  416 int Info (char *stringId, HWND hwnd);
  417 int InfoTopMost (char *stringId, HWND hwnd);
  418 int InfoDirect (const wchar_t *msg, HWND hwnd);
  419 int Warning (char *stringId, HWND hwnd);
  420 int WarningTopMost (char *stringId, HWND hwnd);
  421 int WarningDirect (const wchar_t *warnMsg, HWND hwnd);
  422 int Error (char *stringId, HWND hwnd);
  423 int ErrorRetryCancel (char *stringId, HWND hwnd);
  424 int ErrorDirect (const wchar_t *errMsg, HWND hwnd);
  425 int ErrorTopMost (char *stringId, HWND hwnd);
  426 int AskYesNo (char *stringId, HWND hwnd);
  427 int AskYesNoString (const wchar_t *str, HWND hwnd);
  428 int AskYesNoTopmost (char *stringId, HWND hwnd);
  429 int AskNoYes (char *stringId, HWND hwnd);
  430 int AskNoYesString (const wchar_t *string, HWND hwnd);
  431 int AskOkCancel (char *stringId, HWND hwnd);
  432 int AskWarnYesNo (char *stringId, HWND hwnd);
  433 int AskWarnYesNoString (const wchar_t *string, HWND hwnd);
  434 int AskWarnYesNoTopmost (char *stringId, HWND hwnd);
  435 int AskWarnYesNoStringTopmost (const wchar_t *string, HWND hwnd);
  436 int AskWarnNoYes (char *stringId, HWND hwnd);
  437 int AskWarnNoYesString (const wchar_t *string, HWND hwnd);
  438 int AskWarnNoYesTopmost (char *stringId, HWND hwnd);
  439 int AskWarnOkCancel (char *stringId, HWND hwnd);
  440 int AskWarnCancelOk (char *stringId, HWND hwnd);
  441 int AskErrYesNo (char *stringId, HWND hwnd);
  442 int AskErrNoYes (char *stringId, HWND hwnd);
  443 int AskMultiChoice (void *strings[], BOOL bBold, HWND hwnd);
  444 BOOL ConfigWriteBegin ();
  445 BOOL ConfigWriteEnd (HWND hwnd);
  446 BOOL ConfigWriteString (char *configKey, char *configValue);
  447 BOOL ConfigWriteStringW (char *configKey, wchar_t *configValue);
  448 BOOL ConfigWriteInt (char *configKey, int configValue);
  449 int ConfigReadInt (char *configKey, int defaultValue);
  450 char *ConfigReadString (char *configKey, char *defaultValue, char *str, int maxLen);
  451 void ConfigReadCompareInt(char *configKey, int defaultValue, int* pOutputValue, BOOL bOnlyCheckModified, BOOL* pbModified);
  452 void ConfigReadCompareString (char *configKey, char *defaultValue, char *str, int maxLen, BOOL bOnlyCheckModified, BOOL *pbModified);
  453 void RestoreDefaultKeyFilesParam (void);
  454 BOOL LoadDefaultKeyFilesParam (void);
  455 void Debug (char *format, ...);
  456 void DebugMsgBox (char *format, ...);
  457 BOOL IsOSAtLeast (OSVersionEnum reqMinOS);
  458 BOOL IsOSVersionAtLeast (OSVersionEnum reqMinOS, int reqMinServicePack);
  459 BOOL Is64BitOs ();
  460 BOOL IsServerOS ();
  461 BOOL IsHiddenOSRunning (void);
  462 BOOL EnableWow64FsRedirection (BOOL enable);
  463 BOOL RestartComputer (BOOL bShutdown);
  464 void Applink (const char *dest);
  465 wchar_t *RelativePath2Absolute (wchar_t *szFileName);
  466 void HandleDriveNotReadyError (HWND hwnd);
  467 BOOL CALLBACK CloseTCWindowsEnum( HWND hwnd, LPARAM lParam);
  468 BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam);
  469 BYTE *MapResource (wchar_t *resourceType, int resourceId, PDWORD size);
  470 void InconsistencyResolved (char *msg);
  471 void ReportUnexpectedState (char *techInfo);
  472 BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, wchar_t *lpszFileName, size_t cbFileName, BOOL keepHistory);
  473 BOOL SelectMultipleFilesNext (wchar_t *lpszFileName, size_t cbFileName);
  474 void OpenOnlineHelp ();
  475 BOOL GetPartitionInfo (const wchar_t *deviceName, PPARTITION_INFORMATION rpartInfo);
  476 BOOL GetDeviceInfo (const wchar_t *deviceName, DISK_PARTITION_INFO_STRUCT *info);
  477 BOOL GetDriveGeometry (const wchar_t *deviceName, PDISK_GEOMETRY_EX diskGeometry);
  478 BOOL GetPhysicalDriveGeometry (int driveNumber, PDISK_GEOMETRY diskGeometry);
  479 BOOL IsVolumeDeviceHosted (const wchar_t *lpszDiskFile);
  480 int CompensateXDPI (int val);
  481 int CompensateYDPI (int val);
  482 int CompensateDPIFont (int val);
  483 int GetTextGfxWidth (HWND hwndDlgItem, const wchar_t *text, HFONT hFont);
  484 int GetTextGfxHeight (HWND hwndDlgItem, const wchar_t *text, HFONT hFont);
  485 BOOL ToHyperlink (HWND hwndDlg, UINT ctrlId);
  486 BOOL ToCustHyperlink (HWND hwndDlg, UINT ctrlId, HFONT hFont);
  487 void DisableCloseButton (HWND hwndDlg);
  488 void EnableCloseButton (HWND hwndDlg);
  489 void ToBootPwdField (HWND hwndDlg, UINT ctrlId);
  490 void ToNormalPwdField (HWND hwndDlg, UINT ctrlId);
  491 void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT hFont);
  492 BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize);
  493 BOOL GetSysDevicePaths (HWND hwndDlg);
  494 BOOL DoDriverInstall (HWND hwndDlg);
  495 int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader);
  496 void CloseVolume (OpenVolumeContext *context);
  497 int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pim, BOOL wipeMode);
  498 BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
  499 BOOL IsPagingFileWildcardActive ();
  500 BOOL DisablePagingFile ();
  501 BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  502 BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  503 BOOL InitSecurityTokenLibrary (HWND hwndDlg);
  504 BOOL FileHasReadOnlyAttribute (const wchar_t *path);
  505 BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path);
  506 void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors);
  507 BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str);
  508 int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL* pbDecrypt);
  509 BOOL RemoveDeviceWriteProtection (HWND hwndDlg, wchar_t *devicePath);
  510 void EnableElevatedCursorChange (HWND parent);
  511 BOOL DisableFileCompression (HANDLE file);
  512 BOOL VolumePathExists (const wchar_t *volumePath);
  513 BOOL IsWindowsIsoBurnerAvailable ();
  514 BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath);
  515 BOOL IsApplicationInstalled (const wchar_t *appName);
  516 int GetPim (HWND hwndDlg, UINT ctrlId, int defaultPim);
  517 void SetPim (HWND hwndDlg, UINT ctrlId, int pim);
  518 BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bShowError);
  519 void SetPassword (HWND hwndDlg, UINT ctrlID, char* passValue);
  520 void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id);
  521 HKEY OpenDeviceClassRegKey (const GUID *deviceClassGuid);
  522 LSTATUS DeleteRegistryKey (HKEY, LPCTSTR);
  523 HIMAGELIST  CreateImageList(int cx, int cy, UINT flags, int cInitial, int cGrow);
  524 int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask);
  525 HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz);
  526 void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy);
  527 void AllowMessageInUIPI (UINT msg);
  528 BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize);
  529 BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue);
  530 BOOL CopyTextToClipboard (const wchar_t* txtValue);
  531 BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_t* args);
  532 BOOL GetFreeDriveLetter(WCHAR* pCh);
  533 BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable);
  534 BOOL DeleteDirectory (const wchar_t* szDirName);
  535 INT_PTR SecureDesktopDialogBoxParam (HINSTANCE, LPCWSTR, HWND, DLGPROC, LPARAM);
  536 BOOL VerifyModuleSignature (const wchar_t* path);
  537 void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, BOOL* pbInstallPathDetermined);
  538 BOOL GetSetupconfigLocation (wchar_t* path, DWORD cchSize);
  539 BOOL BufferHasPattern (const unsigned char* buffer, size_t bufferLen, const void* pattern, size_t patternLen);
  540 #ifdef __cplusplus
  541 }
  542 
  543 #include <vector>
  544 #include <string>
  545 
  546 typedef std::vector<unsigned char> ByteArray;
  547 
  548 struct HostDevice
  549 {
  550     HostDevice ()
  551         :
  552         Bootable (false),
  553         ContainsSystem (false),
  554         DynamicVolume (false),
  555         Floppy (false),
  556         IsPartition (false),
  557         IsVirtualPartition (false),
  558         HasUnencryptedFilesystem (false),
  559         Removable (false),
  560         Size (0),
  561         SystemNumber((uint32) -1),
  562         HasVolumeIDs (false)
  563     {
  564         ZeroMemory (VolumeIDs, sizeof (VolumeIDs));
  565     }
  566 
  567     HostDevice (const HostDevice& device)
  568         :
  569         Bootable (device.Bootable),
  570         ContainsSystem (device.ContainsSystem),
  571         DynamicVolume (device.DynamicVolume),
  572         Floppy (device.Floppy),
  573         IsPartition (device.IsPartition),
  574         IsVirtualPartition (device.IsVirtualPartition),
  575         HasUnencryptedFilesystem (device.HasUnencryptedFilesystem),
  576         MountPoint (device.MountPoint),
  577         Name (device.Name),
  578         Path (device.Path),
  579         Removable (device.Removable),
  580         Size (device.Size),
  581         SystemNumber (device.SystemNumber), 
  582         HasVolumeIDs (device.HasVolumeIDs),
  583         Partitions (device.Partitions)
  584     {
  585         memcpy (VolumeIDs, device.VolumeIDs, sizeof (VolumeIDs));
  586     }
  587 
  588     ~HostDevice () {}
  589 
  590     bool Bootable;
  591     bool ContainsSystem;
  592     bool DynamicVolume;
  593     bool Floppy;
  594     bool IsPartition;
  595     bool IsVirtualPartition;
  596     bool HasUnencryptedFilesystem;
  597     std::wstring MountPoint;
  598     std::wstring Name;
  599     std::wstring Path;
  600     bool Removable;
  601     uint64 Size;
  602     uint32 SystemNumber;
  603     BYTE VolumeIDs[TC_VOLUME_TYPE_COUNT][VOLUME_ID_SIZE];
  604     bool HasVolumeIDs;
  605 
  606     std::vector <HostDevice> Partitions;
  607 };
  608 
  609 struct RawDevicesDlgParam
  610 {
  611     std::vector <HostDevice> devices;
  612     wchar_t *pszFileName;
  613 };
  614 
  615 BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, wchar_t *initialDir, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter, const wchar_t *initialFileName = NULL, const wchar_t *defaultExtension = NULL);
  616 std::wstring SingleStringToWide (const std::string &singleString);
  617 std::wstring Utf8StringToWide (const std::string &utf8String);
  618 std::string WideToUtf8String (const std::wstring &wideString);
  619 std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties = false, bool singleList = false, bool noFloppy = true, bool detectUnencryptedFilesystems = false);
  620 std::wstring ToUpperCase (const std::wstring &str);
  621 std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg);
  622 std::wstring GetWindowsEdition ();
  623 std::wstring FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::wstring &path);
  624 std::wstring GetServiceConfigPath (const wchar_t *fileName, bool useLegacy);
  625 std::wstring VolumeGuidPathToDevicePath (std::wstring volumeGuidPath);
  626 std::wstring HarddiskVolumePathToPartitionPath (const std::wstring &harddiskVolumePath);
  627 std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wchar_t *namePattern, bool findDirectory, bool findFile);
  628 std::wstring GetUserFriendlyVersionString (int version);
  629 std::wstring IntToWideString (int val);
  630 std::wstring ArrayToHexWideString (const unsigned char* pbData, int cbData);
  631 bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr);
  632 std::wstring FindDeviceByVolumeID (const BYTE volumeID [VOLUME_ID_SIZE], BOOL bFromService);
  633 void RegisterDriverInf (bool registerFilter, const std::string& filter, const std::string& filterReg, HWND ParentWindow, HKEY regKey);
  634 std::wstring GetTempPathString ();
  635 void CorrectFileName (std::wstring& fileName);
  636 inline std::wstring AppendSrcPos (const wchar_t* msg, const char* srcPos)
  637 {
  638     return std::wstring (msg? msg : L"") + L"\n\nSource: " + SingleStringToWide (srcPos);
  639 }
  640 void UpdateMountableHostDeviceList ();
  641 INT_PTR TextEditDialogBox (BOOL readOnly, HWND parent, const WCHAR* Title, std::string& text);
  642 
  643 // Display a wait dialog while calling the provided callback with the given parameter
  644 typedef void (CALLBACK* WaitThreadProc)(void* pArg, HWND hWaitDlg);
  645 void BringToForeground(HWND hWnd);
  646 void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, void* pArg);
  647 
  648 #endif // __cplusplus
  649 
  650 #endif // TC_HEADER_DLGCODE