VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/doc/html/Keyfiles.html
blob: 03627dbbd8f2e8efedfa5141022fb521a0045fb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>VeraCrypt - Free Open source disk encryption with strong security for the Paranoid</title>
<meta name="description" content="VeraCrypt is free open-source disk encryption software for Windows, Mac OS X and Linux. In case an attacker forces you to reveal the password, VeraCrypt provides plausible deniability. In contrast to file encryption, data encryption performed by VeraCrypt is real-time (on-the-fly), automatic, transparent, needs very little memory, and does not involve temporary unencrypted files."/>
<meta name="keywords" content="encryption, security"/>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div>                      
<a href="https://www.veracrypt.fr/en/Home.html"><img src="VeraCrypt128x128.png" alt="VeraCrypt"/></a>
</div>

<div id="menu">
	<ul>
	  <li><a href="Home.html">Home</a></li>
	  <li><a href="/code/">Source Code</a></li>
	  <li><a href="Downloads.html">Downloads</a></li>
	  <li><a class="active" href="Documentation.html">Documentation</a></li>
	  <li><a href="Donation.html">Donate</a></li>
	  <li><a href="https://sourceforge.net/p/veracrypt/discussion/" target="_blank">Forums</a></li>
	</ul>
</div>

<div>
<p>
<a href="Documentation.html">Documentation</a>           
<img src="arrow_right.gif" alt=">>" style="margin-top: 5px">
<a href="Technical%20Details.html">Technical Details</a>
<img src="arrow_right.gif" alt=">>" style="margin-top: 5px">
<a href="Keyfiles.html">Keyfiles</a>
</p></div>

<div class="wikidoc">
<h1>Keyfiles</h1>
<div style="text-align:left; margin-top:19px; margin-bottom:19px; padding-top:0px; padding-bottom:0px">
<p>VeraCrypt keyfile is a file whose content is combined with a password. The user can use any kind of file as a VeraCrypt keyfile. The user can also generate a keyfile using the built-in keyfile generator, which utilizes the VeraCrypt RNG to generate a file
 with random content (for more information, see the section <a href="Random%20Number%20Generator.html">
<em>Random Number Generator</em></a>).</p>
<p>The maximum size of a keyfile is not limited; however, only its first 1,048,576 bytes (1 MB) are processed (all remaining bytes are ignored due to performance issues connected with processing extremely large files). The user can supply one or more keyfiles
 (the number of keyfiles is not limited).</p>
<p>Keyfiles can be stored on PKCS-11-compliant [23] security tokens and smart cards protected by multiple PIN codes (which can be entered either using a hardware PIN pad or via the VeraCrypt GUI).</p>
<p>Keyfiles are processed and applied to a password using the following method:</p>
<ol>
<li>Let <em>P</em> be a VeraCrypt volume password supplied by user (may be empty)
</li><li>Let <em>KP</em> be the keyfile pool </li><li>Let <em>kpl</em> be the size of the keyfile pool <em>KP</em>, in bytes (64, i.e., 512 bits);
<p>kpl must be a multiple of the output size of a hash function H</p>
</li><li>Let <em>pl</em> be the length of the password <em>P</em>, in bytes (in the current version: 0 &le;
<em>pl</em> &le; 64) </li><li>if <em>kpl &gt; pl</em>, append (<em>kpl &ndash; pl</em>) zero bytes to the password
<em>P</em> (thus <em>pl = kpl</em>) </li><li>Fill the keyfile pool <em>KP</em> with <em>kpl</em> zero bytes. </li><li>For each keyfile perform the following steps:
<ol type="a">
<li>Set the position of the keyfile pool cursor to the beginning of the pool </li><li>Initialize the hash function <em>H</em> </li><li>Load all bytes of the keyfile one by one, and for each loaded byte perform the following steps:
<ol type="i">
<li>Hash the loaded byte using the hash function <em>H</em> without initializing the hash, to obtain an intermediate hash (state)
<em>M.</em> Do not finalize the hash (the state is retained for next round). </li><li>Divide the state <em>M</em> into individual bytes.<br>
For example, if the hash output size is 4 bytes, (<em>T</em><sub>0</sub> || <em>T</em><sub>1</sub> ||
<em>T</em><sub>2</sub> || <em>T</em><sub>3</sub>) = <em>M</em> </li><li>Write these bytes (obtained in step 7.c.ii) individually to the keyfile pool with the modulo 2<sup>8</sup> addition operation (not by replacing the old values in the pool) at the position of the pool cursor. After a byte is written, the pool cursor position
 is advanced by one byte. When the cursor reaches the end of the pool, its position is set to the beginning of the pool.
</li></ol>
</li></ol>
</li><li>Apply the content of the keyfile pool to the password <em>P</em> using the following method:
<ol type="a">
<li>Divide the password <em>P</em> into individual bytes <em>B</em><sub>0</sub>...<em>B</em><sub>pl-1</sub>.<br>
Note that if the password was shorter than the keyfile pool, then the password was padded with zero bytes to the length of the pool in Step 5 (hence, at this point the length of the password is always greater than or equal to the length of the keyfile pool).
</li><li>Divide the keyfile pool <em>KP</em> into individual bytes <em>G</em><sub>0</sub>...<em>G</em><sub>kpl-1</sub>
</li><li>For 0 &le; i &lt; kpl perform: Bi = Bi &oplus; Gi </li><li><em>P</em> = <em>B</em><sub>0</sub> || <em>B</em><sub>1</sub> || ... || <em>B</em><sub>pl-2</sub> ||
<em>B</em><sub>pl-1</sub> </li></ol>
</li><li>The password <em>P</em> (after the keyfile pool content has been applied to it) is now passed to the header key derivation function PBKDF2 (PKCS #5 v2), which processes it (along with salt and other data) using a cryptographically secure hash algorithm
 selected by the user (e.g., SHA-512). See the section <a href="Header%20Key%20Derivation.html">
<em>Header Key Derivation, Salt, and Iteration Count</em></a> for more information.
</li></ol>
<p>The role of the hash function <em>H</em> is merely to perform diffusion [2]. CRC-32 is used as the hash function
<em>H</em>. Note that the output of CRC-32 is subsequently processed using a cryptographically secure hash algorithm: The keyfile pool content (in addition to being hashed using CRC-32) is applied to the password, which is then passed to the header key derivation
 function PBKDF2 (PKCS #5 v2), which processes it (along with salt and other data) using a cryptographically secure hash algorithm selected by the user (e.g., SHA-512). The resultant values are used to form the header key and the secondary header key (XTS mode).</p>
<p>&nbsp;</p>
<p><a href="Personal%20Iterations%20Multiplier%20%28PIM%29.html" style="text-align:left; color:#0080c0; text-decoration:none; font-weight:bold.html">Next Section &gt;&gt;</a></p>
</div>
</div><div class="ClearBoth"></div></body></html>
INSTANCE hInst; extern int SystemEncryptionStatus; extern WipeAlgorithmId nWipeMode; extern BOOL bSysPartitionSelected; extern BOOL bSysDriveSelected; extern wchar_t SysPartitionDevicePath [TC_MAX_PATH]; extern wchar_t SysDriveDevicePath [TC_MAX_PATH]; extern char bCachedSysDevicePathsValid; extern BOOL bHyperLinkBeingTracked; extern BOOL bInPlaceEncNonSysPending; extern BOOL PimEnable; extern BOOL KeyFilesEnable; extern KeyFile *FirstKeyFile; extern KeyFilesDlgParam defaultKeyFilesParam; extern BOOL UacElevated; extern BOOL IgnoreWmDeviceChange; extern BOOL DeviceChangeBroadcastDisabled; extern BOOL LastMountedVolumeDirty; extern BOOL MountVolumesAsSystemFavorite; extern BOOL FavoriteMountOnArrivalInProgress; extern BOOL MultipleMountOperationInProgress; enum tc_app_msg_ids { /* WARNING: Changing these values or their meanings may cause incompatibility with other versions (for example, if a new version of the TrueCrypt installer needed to shut down this version of TrueCrypt during upgrade, it could fail or do something unwanted because the signal value would be incorrect). When adding a new constant, verify that the value is unique within this block and that it is less than WM_APP+16383. */ // Common (inter-app) TC_APPMSG_CLOSE_BKG_TASK = WM_APP + 4, // Changing this value will prevent smooth upgrades from pre-5.x versions TC_APPMSG_SYSENC_CONFIG_UPDATE = WM_APP + 101, TC_APPMSG_TASKBAR_ICON = WM_APP + 102, TC_APPMSG_LOAD_TEXT_BOX_CONTENT = WM_APP + 103, // Mount TC_APPMSG_MOUNT_ENABLE_DISABLE_CONTROLS = WM_APP + 201, TC_APPMSG_MOUNT_SHOW_WINDOW = WM_APP + 202, TC_APPMSG_PREBOOT_PASSWORD_MODE = WM_APP + 203, // Format TC_APPMSG_VOL_TRANSFORM_THREAD_ENDED = WM_APP + 301, TC_APPMSG_FORMAT_FINISHED = WM_APP + 302, TC_APPMSG_FORMAT_USER_QUIT = WM_APP + 303, TC_APPMSG_PERFORM_POST_WMINIT_TASKS = WM_APP + 304, TC_APPMSG_PERFORM_POST_SYSENC_WMINIT_TASKS = WM_APP + 305, TC_APPMSG_NONSYS_INPLACE_ENC_FINISHED = WM_APP + 306, // Setup TC_APPMSG_INSTALL_SUCCESS = WM_APP + 401, TC_APPMSG_UNINSTALL_SUCCESS = WM_APP + 402, TC_APPMSG_EXTRACTION_SUCCESS = WM_APP + 403, TC_APPMSG_INSTALL_FAILURE = WM_APP + 404, TC_APPMSG_UNINSTALL_FAILURE = WM_APP + 405, TC_APPMSG_EXTRACTION_FAILURE = WM_APP + 406 }; enum system_encryption_status { /* WARNING: As these values are written to config files, if they or their meanings are changed, incompatiblity with other versions may arise (upgrade, downgrade, etc.). When adding a new constant, verify that the value is unique within this block. */ SYSENC_STATUS_NONE = 0, 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). SYSENC_STATUS_ENCRYPTING = 400, SYSENC_STATUS_DECRYPTING = 600 }; enum vol_creation_wizard_modes { WIZARD_MODE_FILE_CONTAINER = 0, WIZARD_MODE_NONSYS_DEVICE, WIZARD_MODE_SYS_DEVICE }; typedef struct { BOOL VolumeIsOpen; CRYPTO_INFO *CryptoInfo; BOOL IsDevice; HANDLE HostFileHandle; uint64 HostSize; BOOL TimestampsValid; FILETIME CreationTime; FILETIME LastWriteTime; FILETIME LastAccessTime; } OpenVolumeContext; #define DEFAULT_VOL_CREATION_WIZARD_MODE WIZARD_MODE_FILE_CONTAINER #define ICON_HAND MB_ICONHAND #define YES_NO MB_YESNO #define ISO_BURNER_TOOL L"isoburn.exe" #define PRINT_TOOL L"notepad.exe" void cleanup ( void ); void LowerCaseCopy ( wchar_t *lpszDest , const wchar_t *lpszSource ); void UpperCaseCopy ( wchar_t *lpszDest , size_t cbDest, const wchar_t *lpszSource ); void CreateFullVolumePath ( wchar_t *lpszDiskFile , size_t cbDiskFile, const wchar_t *lpszFileName , BOOL *bDevice ); int FakeDosNameForDevice ( const wchar_t *lpszDiskFile , wchar_t *lpszDosDevice , size_t cbDosDevice, wchar_t *lpszCFDevice , size_t cbCFDevice, BOOL bNameOnly ); int RemoveFakeDosName ( wchar_t *lpszDiskFile , wchar_t *lpszDosDevice ); void AbortProcessDirect ( wchar_t *abortMsg ); void AbortProcess ( char *stringId ); void AbortProcessSilent ( void ); void *err_malloc ( size_t size ); char *err_strdup ( char *lpszText ); DWORD handleWin32Error ( HWND hwndDlg, const char* srcPos ); BOOL IsDiskReadError (DWORD error); BOOL IsDiskWriteError (DWORD error); BOOL IsDiskError (DWORD error); BOOL translateWin32Error ( wchar_t *lpszMsgBuf , int nWSizeOfBuf ); BOOL CALLBACK AboutDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam ); static BOOL CALLBACK StaticModelessWaitDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); void DisplayStaticModelessWaitDlg (HWND parent); void CloseStaticModelessWaitDlg (void); BOOL IsButtonChecked ( HWND hButton ); void CheckButton ( HWND hButton ); void LeftPadString (wchar_t *szTmp, int len, int targetLen, wchar_t filler); void InitDialog ( HWND hwndDlg ); void ProcessPaintMessages (HWND hwnd, int maxMessagesToProcess); HDC CreateMemBitmap ( HINSTANCE hInstance , HWND hwnd , wchar_t *resource ); HBITMAP RenderBitmap ( wchar_t *resource , HWND hwndDest , int x , int y , int nWidth , int nHeight , BOOL bDirectRender , BOOL bKeepAspectRatio); LRESULT CALLBACK RedTick ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam ); BOOL RegisterRedTick ( HINSTANCE hInstance ); BOOL UnregisterRedTick ( HINSTANCE hInstance ); LRESULT CALLBACK SplashDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam ); void WaitCursor ( void ); void NormalCursor ( void ); void ArrowWaitCursor ( void ); void HandCursor (); void AddComboPair (HWND hComboBox, const wchar_t *lpszItem, int value); void SelectAlgo ( HWND hComboBox , int *nCipher ); void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption, BOOL bHeaderWipe); wchar_t *GetWipeModeName (WipeAlgorithmId modeId); wchar_t *GetPathType (const wchar_t *path, BOOL bUpperCase, BOOL *bIsPartition); LRESULT CALLBACK CustomDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam ); BOOL TCCreateMutex (volatile HANDLE *hMutex, wchar_t *name); void TCCloseMutex (volatile HANDLE *hMutex); BOOL MutexExistsOnSystem (wchar_t *name); BOOL CreateSysEncMutex (void); BOOL InstanceHasSysEncMutex (void); void CloseSysEncMutex (void); BOOL CreateNonSysInplaceEncMutex (void); BOOL InstanceHasNonSysInplaceEncMutex (void); void CloseNonSysInplaceEncMutex (void); BOOL NonSysInplaceEncInProgressElsewhere (void); BOOL CreateDriverSetupMutex (void); void CloseDriverSetupMutex (void); BOOL CreateAppSetupMutex (void); BOOL InstanceHasAppSetupMutex (void); void CloseAppSetupMutex (void); BOOL IsTrueCryptInstallerRunning (void); uint32 ReadDriverConfigurationFlags (); uint32 ReadEncryptionThreadPoolFreeCpuCountLimit (); BOOL LoadSysEncSettings (); int LoadNonSysInPlaceEncSettings (WipeAlgorithmId *wipeAlgorithm); void RemoveNonSysInPlaceEncNotifications (void); void SavePostInstallTasksSettings (int command); void DoPostInstallTasks (HWND hwndDlg); void InitOSVersionInfo (); void InitApp ( HINSTANCE hInstance, wchar_t *lpszCommandLine ); void FinalizeApp (void); void InitHelpFileName (void); BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem); void NotifyDriverOfPortableMode (void); int GetAvailableFixedDisks ( HWND hComboBox , char *lpszRootPath ); int GetAvailableRemovables ( HWND hComboBox , char *lpszRootPath ); int IsSystemDevicePath (const wchar_t *path, HWND hwndDlg, BOOL bReliableRequired); int IsNonSysPartitionOnSysDrive (const wchar_t *path); BOOL CALLBACK RawDevicesDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam ); INT_PTR TextInfoDialogBox (int nID); BOOL CALLBACK TextInfoDialogBoxDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); char * GetLegalNotices (); BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); void UserEnrichRandomPool (HWND hwndDlg); BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); int DriverAttach ( void ); BOOL CALLBACK CipherTestDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam ); void ResetCipherTest ( HWND hwndDlg , int idTestCipher ); void ResetCurrentDirectory (); BOOL BrowseFiles (HWND hwndDlg, char *stringId, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter); BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, wchar_t *dirName); void handleError ( HWND hwndDlg , int code, const char* srcPos ); BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const wchar_t *fileName); void LocalizeDialog ( HWND hwnd, char *stringId ); void OpenVolumeExplorerWindow (int driveNo); static BOOL CALLBACK CloseVolumeExplorerWindowsEnum( HWND hwnd, LPARAM driveNo); BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo); BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue); BOOL CheckCapsLock (HWND hwnd, BOOL quiet); BOOL CheckFileExtension (wchar_t *fileName); void CorrectFileName (wchar_t* fileName); void IncreaseWrongPwdRetryCount (int count); void ResetWrongPwdRetryCount (void); BOOL WrongPwdRetryCountOverLimit (void); DWORD GetUsedLogicalDrives (void); int GetFirstAvailableDrive (); int GetLastAvailableDrive (); BOOL IsDriveAvailable (int driveNo); BOOL IsDeviceMounted (wchar_t *deviceName); int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced); void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap); 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); BOOL UnmountVolume (HWND hwndDlg , int nDosDriveNo, BOOL forceUnmount); BOOL UnmountVolumeAfterFormatExCall (HWND hwndDlg, int nDosDriveNo); BOOL IsPasswordCacheEmpty (void); BOOL IsMountedVolume (const wchar_t *volname); int GetMountedVolumeDriveNo (wchar_t *volname); BOOL IsAdmin (void); BOOL IsBuiltInAdmin (); BOOL IsUacSupported (); BOOL ResolveSymbolicLink (const wchar_t *symLinkName, PWSTR targetName, size_t cbTargetName); int GetDiskDeviceDriveLetter (PWSTR deviceName); int FileSystemAppearsEmpty (const wchar_t *devicePath); __int64 GetStatsFreeSpaceOnPartition (const wchar_t *devicePath, float *percent, __int64 *occupiedBytes, BOOL silent); __int64 GetDeviceSize (const wchar_t *devicePath); HANDLE DismountDrive (wchar_t *devName, wchar_t *devicePath); int64 FindString (const char *buf, const char *str, int64 bufLen, int64 strLen, int64 startOffset); BOOL FileExists (const wchar_t *filePathPtr); __int64 FindStringInFile (const wchar_t *filePath, const char *str, int strLen); BOOL TCCopyFile (wchar_t *sourceFileName, wchar_t *destinationFile); BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile, DWORD inputLength, BOOL bAppend, BOOL bRenameIfFailed); BOOL TCFlushFile (FILE *f); BOOL PrintHardCopyTextUTF16 (wchar_t *text, wchar_t *title, size_t byteLen); void GetSpeedString (unsigned __int64 speed, wchar_t *str, size_t cbStr); BOOL IsNonInstallMode (); BOOL DriverUnload (); LRESULT SetCheckBox (HWND hwndDlg, int dlgItem, BOOL state); BOOL GetCheckBox (HWND hwndDlg, int dlgItem); void SetListScrollHPos (HWND hList, int topMostVisibleItem); void ManageStartupSeq (void); void ManageStartupSeqWiz (BOOL bRemove, const wchar_t *arg); void CleanLastVisitedMRU (void); void ClearHistory (HWND hwndDlgItem); LRESULT ListItemAdd (HWND list, int index, const wchar_t *string); LRESULT ListSubItemSet (HWND list, int index, int subIndex, const wchar_t *string); BOOL GetMountList (MOUNT_LIST_STRUCT *list); int GetDriverRefCount (); void GetSizeString (unsigned __int64 size, wchar_t *str, size_t cbStr); __int64 GetFileSize64 (const wchar_t *path); BOOL LoadInt16 (const wchar_t *filePath, int *result, __int64 fileOffset); BOOL LoadInt32 (const wchar_t *filePath, unsigned __int32 *result, __int64 fileOffset); char *LoadFile (const wchar_t *fileName, DWORD *size); char *LoadFileBlock (const wchar_t *fileName, __int64 fileOffset, DWORD count); wchar_t *GetModPath (wchar_t *path, int maxSize); wchar_t *GetConfigPath (wchar_t *fileName); wchar_t *GetProgramConfigPath (wchar_t *fileName); wchar_t GetSystemDriveLetter (void); void OpenPageHelp (HWND hwndDlg, int nPage); void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *text, BOOL warning); void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd); void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd); void WarningBalloon (char *headingStringId, char *textStringId, HWND hwnd); void WarningBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd); int Info (char *stringId, HWND hwnd); int InfoTopMost (char *stringId, HWND hwnd); int InfoDirect (const wchar_t *msg, HWND hwnd); int Warning (char *stringId, HWND hwnd); int WarningTopMost (char *stringId, HWND hwnd); int WarningDirect (const wchar_t *warnMsg, HWND hwnd); int Error (char *stringId, HWND hwnd); int ErrorRetryCancel (char *stringId, HWND hwnd); int ErrorDirect (const wchar_t *errMsg, HWND hwnd); int ErrorTopMost (char *stringId, HWND hwnd); int AskYesNo (char *stringId, HWND hwnd); int AskYesNoString (const wchar_t *str, HWND hwnd); int AskYesNoTopmost (char *stringId, HWND hwnd); int AskNoYes (char *stringId, HWND hwnd); int AskNoYesString (const wchar_t *string, HWND hwnd); int AskOkCancel (char *stringId, HWND hwnd); int AskWarnYesNo (char *stringId, HWND hwnd); int AskWarnYesNoString (const wchar_t *string, HWND hwnd); int AskWarnYesNoTopmost (char *stringId, HWND hwnd); int AskWarnYesNoStringTopmost (const wchar_t *string, HWND hwnd); int AskWarnNoYes (char *stringId, HWND hwnd); int AskWarnNoYesString (const wchar_t *string, HWND hwnd); int AskWarnNoYesTopmost (char *stringId, HWND hwnd); int AskWarnOkCancel (char *stringId, HWND hwnd); int AskWarnCancelOk (char *stringId, HWND hwnd); int AskErrYesNo (char *stringId, HWND hwnd); int AskErrNoYes (char *stringId, HWND hwnd); int AskMultiChoice (void *strings[], BOOL bBold, HWND hwnd); BOOL ConfigWriteBegin (); BOOL ConfigWriteEnd (HWND hwnd); BOOL ConfigWriteString (char *configKey, char *configValue); BOOL ConfigWriteStringW (char *configKey, wchar_t *configValue); BOOL ConfigWriteInt (char *configKey, int configValue); int ConfigReadInt (char *configKey, int defaultValue); char *ConfigReadString (char *configKey, char *defaultValue, char *str, int maxLen); void ConfigReadCompareInt(char *configKey, int defaultValue, int* pOutputValue, BOOL bOnlyCheckModified, BOOL* pbModified); void ConfigReadCompareString (char *configKey, char *defaultValue, char *str, int maxLen, BOOL bOnlyCheckModified, BOOL *pbModified); void RestoreDefaultKeyFilesParam (void); BOOL LoadDefaultKeyFilesParam (void); void Debug (char *format, ...); void DebugMsgBox (char *format, ...); BOOL IsOSAtLeast (OSVersionEnum reqMinOS); BOOL IsOSVersionAtLeast (OSVersionEnum reqMinOS, int reqMinServicePack); BOOL Is64BitOs (); BOOL IsServerOS (); BOOL IsHiddenOSRunning (void); BOOL EnableWow64FsRedirection (BOOL enable); BOOL RestartComputer (void); void Applink (char *dest, BOOL bSendOS, char *extraOutput); wchar_t *RelativePath2Absolute (wchar_t *szFileName); void HandleDriveNotReadyError (HWND hwnd); BOOL CALLBACK CloseTCWindowsEnum( HWND hwnd, LPARAM lParam); BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam); BYTE *MapResource (wchar_t *resourceType, int resourceId, PDWORD size); void InconsistencyResolved (char *msg); void ReportUnexpectedState (char *techInfo); BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, wchar_t *lpszFileName, size_t cbFileName, BOOL keepHistory); BOOL SelectMultipleFilesNext (wchar_t *lpszFileName, size_t cbFileName); void OpenOnlineHelp (); BOOL GetPartitionInfo (const wchar_t *deviceName, PPARTITION_INFORMATION rpartInfo); BOOL GetDeviceInfo (const wchar_t *deviceName, DISK_PARTITION_INFO_STRUCT *info); BOOL GetDriveGeometry (const wchar_t *deviceName, PDISK_GEOMETRY diskGeometry); BOOL IsVolumeDeviceHosted (const wchar_t *lpszDiskFile); int CompensateXDPI (int val); int CompensateYDPI (int val); int CompensateDPIFont (int val); int GetTextGfxWidth (HWND hwndDlgItem, const wchar_t *text, HFONT hFont); int GetTextGfxHeight (HWND hwndDlgItem, const wchar_t *text, HFONT hFont); BOOL ToHyperlink (HWND hwndDlg, UINT ctrlId); BOOL ToCustHyperlink (HWND hwndDlg, UINT ctrlId, HFONT hFont); void DisableCloseButton (HWND hwndDlg); void EnableCloseButton (HWND hwndDlg); void ToBootPwdField (HWND hwndDlg, UINT ctrlId); void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT hFont); BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize); BOOL GetSysDevicePaths (HWND hwndDlg); BOOL DoDriverInstall (HWND hwndDlg); int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader); void CloseVolume (OpenVolumeContext *context); int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pim, BOOL wipeMode); BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly); BOOL IsPagingFileWildcardActive (); BOOL DisablePagingFile (); BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL InitSecurityTokenLibrary (HWND hwndDlg); BOOL FileHasReadOnlyAttribute (const wchar_t *path); BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path); void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors); BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str); int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL* pbDecrypt); BOOL RemoveDeviceWriteProtection (HWND hwndDlg, wchar_t *devicePath); void EnableElevatedCursorChange (HWND parent); BOOL DisableFileCompression (HANDLE file); BOOL VolumePathExists (const wchar_t *volumePath); BOOL IsWindowsIsoBurnerAvailable (); BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath); BOOL IsApplicationInstalled (const wchar_t *appName); int GetPim (HWND hwndDlg, UINT ctrlId); void SetPim (HWND hwndDlg, UINT ctrlId, int pim); BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bShowError); void SetPassword (HWND hwndDlg, UINT ctrlID, char* passValue); void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id); HKEY OpenDeviceClassRegKey (const GUID *deviceClassGuid); LSTATUS DeleteRegistryKey (HKEY, LPCTSTR); HIMAGELIST CreateImageList(int cx, int cy, UINT flags, int cInitial, int cGrow); int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask); HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz); #ifdef __cplusplus } #include <vector> #include <string> struct HostDevice { HostDevice () : Bootable (false), ContainsSystem (false), DynamicVolume (false), Floppy (false), IsPartition (false), IsVirtualPartition (false), HasUnencryptedFilesystem (false), Removable (false), Size (0), SystemNumber((uint32) -1) { } ~HostDevice () { } bool Bootable; bool ContainsSystem; bool DynamicVolume; bool Floppy; bool IsPartition; bool IsVirtualPartition; bool HasUnencryptedFilesystem; std::wstring MountPoint; std::wstring Name; std::wstring Path; bool Removable; uint64 Size; uint32 SystemNumber; std::vector <HostDevice> Partitions; }; struct RawDevicesDlgParam { std::vector <HostDevice> devices; wchar_t *pszFileName; }; 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); std::wstring SingleStringToWide (const std::string &singleString); std::wstring Utf8StringToWide (const std::string &utf8String); std::string WideToUtf8String (const std::wstring &wideString); std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties = false, bool singleList = false, bool noFloppy = true, bool detectUnencryptedFilesystems = false); std::wstring ToUpperCase (const std::wstring &str); std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg); std::wstring GetWindowsEdition (); std::wstring FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::wstring &path); std::wstring GetServiceConfigPath (const wchar_t *fileName, bool useLegacy); std::wstring VolumeGuidPathToDevicePath (std::wstring volumeGuidPath); std::wstring HarddiskVolumePathToPartitionPath (const std::wstring &harddiskVolumePath); std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wchar_t *namePattern, bool findDirectory, bool findFile); std::wstring GetUserFriendlyVersionString (int version); std::wstring IntToWideString (int val); void RegisterDriverInf (bool registerFilter, const std::string& filter, const std::string& filterReg, HWND ParentWindow, HKEY regKey); std::wstring GetTempPathString (); inline std::wstring AppendSrcPos (const wchar_t* msg, const char* srcPos) { return std::wstring (msg? msg : L"") + L"\n\nSource: " + SingleStringToWide (srcPos); } // Display a wait dialog while calling the provided callback with the given parameter typedef void (CALLBACK* WaitThreadProc)(void* pArg, HWND hWaitDlg); void BringToForeground(HWND hWnd); void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, void* pArg); #endif // __cplusplus #endif // TC_HEADER_DLGCODE