|
|
1.1.1.10 root 1: /*
2: Legal Notice: The source code contained in this file has been derived from
3: the source code of Encryption for the Masses 2.02a, which is Copyright (c)
4: Paul Le Roux and which is covered by the 'License Agreement for Encryption
5: for the Masses'. Modifications and additions to that source code contained
6: in this file are Copyright (c) TrueCrypt Foundation and are covered by the
1.1.1.11! root 7: TrueCrypt License 2.3 the full text of which is contained in the file
1.1.1.10 root 8: License.txt included in TrueCrypt binary and source code distribution
9: packages. */
1.1.1.6 root 10:
11: #include "Common.h"
12: #include "Apidrvr.h"
13: #include "Keyfiles.h"
14:
1.1.1.10 root 15: #ifdef __cplusplus
16: extern "C" {
17: #endif
18:
1.1.1.6 root 19: /* IDs for dynamically generated GUI elements */
20: #define IDPM_CHECK_FILESYS 500001
21: #define IDPM_REPAIR_FILESYS 500002
22: #define IDPM_OPEN_VOLUME 500003
23: #define IDM_SHOW_HIDE 500004
1.1.1.10 root 24: #define IDM_HOMEPAGE_SYSTRAY 500005
1.1.1.5 root 25:
1.1.1.4 root 26: #define IDC_ABOUT 0x7fff /* ID for AboutBox on system menu in wm_user range */
27:
1.1.1.10 root 28: #define SELDEVFLAG_CONTAINS_PARTITIONS 0x00000001L
29: #define SELDEVFLAG_VIRTUAL_PARTITION 0x00000002L
1.1.1.11! root 30: #define SELDEVFLAG_REMOVABLE_HOST_DEVICE 0x00000004L
1.1.1.10 root 31:
1.1.1.11! root 32: #define UNMOUNT_MAX_AUTO_RETRIES 10
1.1.1.5 root 33: #define UNMOUNT_AUTO_RETRY_DELAY 50
1.1 root 34:
1.1.1.10 root 35: #define MAX_MULTI_CHOICES 10 /* Maximum number of options for mutliple-choice dialog */
36:
1.1.1.6 root 37: #define FILE_DEFAULT_KEYFILES "Default Keyfiles.xml"
38:
1.1.1.11! root 39: #ifndef USER_DEFAULT_SCREEN_DPI
! 40: #define USER_DEFAULT_SCREEN_DPI 96
! 41: #endif
! 42:
! 43: #if (USER_DEFAULT_SCREEN_DPI != 96)
! 44: #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).
! 45: #endif
! 46:
1.1.1.9 root 47: extern char *LastDialogId;
1.1 root 48: extern char szHelpFile[TC_MAX_PATH];
1.1.1.6 root 49: extern char szHelpFile2[TC_MAX_PATH];
50: extern HFONT hFixedDigitFont;
1.1 root 51: extern HFONT hBoldFont;
52: extern HFONT hTitleFont;
53: extern HFONT hFixedFont;
54: extern HFONT hUserFont;
55: extern HFONT hUserUnderlineFont;
56: extern HFONT hUserBoldFont;
1.1.1.11! root 57: extern int ScreenDPI;
! 58: extern double DlgAspectRatio;
1.1.1.6 root 59: extern HWND MainDlg;
60: extern BOOL Silent;
1.1.1.9 root 61: extern BOOL bHistory;
1.1.1.6 root 62: extern BOOL bPreserveTimestamp;
63: extern wchar_t *lpszTitle;
1.1 root 64: extern int nCurrentOS;
65: extern int CurrentOSMajor;
66: extern int CurrentOSMinor;
1.1.1.9 root 67: extern BOOL RemoteSession;
1.1 root 68: extern HANDLE hDriver;
69: extern HINSTANCE hInst;
70:
1.1.1.6 root 71: extern BOOL KeyFilesEnable;
72: extern KeyFile *FirstKeyFile;
73: extern KeyFilesDlgParam defaultKeyFilesParam;
1.1.1.10 root 74: extern BOOL UacElevated;
1.1.1.11! root 75: extern BOOL IgnoreWmDeviceChange;
1.1.1.6 root 76:
77: enum
78: {
79: WIN_UNKNOWN = 0,
80: WIN_31,
81: WIN_95,
82: WIN_98,
83: WIN_ME,
84: WIN_NT3,
85: WIN_NT4,
86: WIN_2000,
87: WIN_XP,
1.1.1.10 root 88: WIN_XP64,
89: WIN_SERVER_2003,
1.1.1.6 root 90: WIN_VISTA,
1.1.1.10 root 91: WIN_VISTA_OR_LATER
1.1.1.6 root 92: };
1.1 root 93:
94: #define ICON_HAND MB_ICONHAND
95: #define YES_NO MB_YESNO
96:
97: #ifdef _UNICODE
98: #define WINMAIN wWinMain
99: #else
100: #define WINMAIN WinMain
101: #endif
102:
1.1.1.6 root 103: #define FILE_CONFIGURATION "Configuration.xml"
104:
1.1 root 105: void cleanup ( void );
106: void LowerCaseCopy ( char *lpszDest , char *lpszSource );
107: void UpperCaseCopy ( char *lpszDest , char *lpszSource );
108: void CreateFullVolumePath ( char *lpszDiskFile , char *lpszFileName , BOOL *bDevice );
109: int FakeDosNameForDevice ( char *lpszDiskFile , char *lpszDosDevice , char *lpszCFDevice , BOOL bNameOnly );
110: int RemoveFakeDosName ( char *lpszDiskFile , char *lpszDosDevice );
1.1.1.6 root 111: void AbortProcess ( char *stringId );
1.1.1.4 root 112: void AbortProcessSilent ( void );
1.1 root 113: void *err_malloc ( size_t size );
114: char *err_strdup ( char *lpszText );
1.1.1.4 root 115: DWORD handleWin32Error ( HWND hwndDlg );
1.1.1.6 root 116: BOOL translateWin32Error ( wchar_t *lpszMsgBuf , int nSizeOfBuf );
1.1.1.11! root 117: BOOL CALLBACK AboutDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
1.1 root 118: BOOL IsButtonChecked ( HWND hButton );
119: void CheckButton ( HWND hButton );
120: void ToSBCS ( LPWSTR lpszText );
121: void ToUNICODE ( char *lpszText );
122: void InitDialog ( HWND hwndDlg );
123: HDC CreateMemBitmap ( HINSTANCE hInstance , HWND hwnd , char *resource );
1.1.1.11! root 124: HBITMAP RenderBitmap ( char *resource , HWND hwndDest , int x , int y , int nWidth , int nHeight , BOOL bDirectRender , BOOL bKeepAspectRatio);
1.1.1.6 root 125: LRESULT CALLBACK RedTick ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );
126: BOOL RegisterRedTick ( HINSTANCE hInstance );
127: BOOL UnregisterRedTick ( HINSTANCE hInstance );
1.1 root 128: LRESULT CALLBACK SplashDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );
129: void WaitCursor ( void );
130: void NormalCursor ( void );
131: void ArrowWaitCursor ( void );
1.1.1.10 root 132: void HandCursor ();
1.1.1.6 root 133: void AddComboPair (HWND hComboBox, char *lpszItem, int value);
134: void AddComboPairW (HWND hComboBox, wchar_t *lpszItem, int value);
135: void SelectAlgo ( HWND hComboBox , int *nCipher );
1.1 root 136: LRESULT CALLBACK CustomDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );
1.1.1.10 root 137: void InitApp ( HINSTANCE hInstance, char *lpszCommandLine );
1.1.1.6 root 138: void InitHelpFileName (void);
1.1 root 139: BOOL OpenDevice ( char *lpszPath , OPEN_TEST_STRUCT *driver );
140: int GetAvailableFixedDisks ( HWND hComboBox , char *lpszRootPath );
141: int GetAvailableRemovables ( HWND hComboBox , char *lpszRootPath );
1.1.1.11! root 142: BOOL CALLBACK RawDevicesDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
! 143: BOOL CALLBACK LegalNoticesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
1.1.1.6 root 144: char * GetLegalNotices ();
1.1.1.11! root 145: BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
! 146: BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
1.1.1.10 root 147: BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
1.1 root 148: int DriverAttach ( void );
1.1.1.4 root 149: BOOL SeekHiddenVolHeader (HFILE dev, unsigned __int64 volSize, BOOL deviceFlag);
1.1.1.6 root 150: BOOL CALLBACK CipherTestDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam );
151: void ResetCipherTest ( HWND hwndDlg , int idTestCipher );
1.1.1.7 root 152: BOOL BrowseFiles (HWND hwndDlg, char *stringId, char *lpszFileName, BOOL keepHistory, BOOL saveMode);
1.1.1.10 root 153: BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, char *initialDir, char *lpszFileName, BOOL keepHistory, BOOL saveMode);
1.1.1.6 root 154: BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, char *dirName);
1.1 root 155: void handleError ( HWND hwndDlg , int code );
1.1.1.6 root 156: void LocalizeDialog ( HWND hwnd, char *stringId );
1.1.1.4 root 157: void OpenVolumeExplorerWindow (int driveNo);
158: static BOOL CALLBACK CloseVolumeExplorerWindowsEnum( HWND hwnd, LPARAM driveNo);
159: BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo);
160: BOOL CheckCapsLock (HWND hwnd, BOOL quiet);
1.1.1.10 root 161: BOOL CheckFileExtension (char *fileName);
1.1.1.4 root 162: int GetFirstAvailableDrive ();
163: int GetLastAvailableDrive ();
164: BOOL IsDriveAvailable (int driveNo);
1.1.1.10 root 165: BOOL IsDeviceMounted (char *deviceName);
1.1.1.4 root 166: int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced);
1.1.1.5 root 167: void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap);
1.1.1.6 root 168: int MountVolume (HWND hwndDlg, int driveNo, char *volumePath, Password *password, BOOL cachePassword, BOOL sharedAccess, MountOptions *mountOptions, BOOL quiet, BOOL bReportWrongPassword);
1.1.1.4 root 169: BOOL UnmountVolume (HWND hwndDlg , int nDosDriveNo, BOOL forceUnmount);
170: BOOL IsPasswordCacheEmpty (void);
171: BOOL IsMountedVolume (char *volname);
1.1.1.11! root 172: int GetMountedVolumeDriveNo (char *volname);
1.1.1.4 root 173: BOOL IsAdmin (void);
1.1.1.10 root 174: BOOL IsUacSupported ();
1.1.1.4 root 175: BOOL ResolveSymbolicLink (PWSTR symLinkName, PWSTR targetName);
176: int GetDiskDeviceDriveLetter (PWSTR deviceName);
1.1.1.10 root 177: HANDLE DismountDrive (char *devName);
1.1.1.5 root 178: BOOL TCCopyFile (char *sourceFileName, char *destinationFile);
1.1.1.6 root 179: int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, char *lpszVolume);
180: int RestoreVolumeHeader (HWND hwndDlg, char *lpszVolume);
181: void GetSpeedString (unsigned __int64 speed, wchar_t *str);
1.1.1.5 root 182: BOOL IsNonInstallMode ();
1.1.1.6 root 183: BOOL DriverUnload ();
184: LRESULT SetCheckBox (HWND hwndDlg, int dlgItem, BOOL state);
185: BOOL GetCheckBox (HWND hwndDlg, int dlgItem);
186: void CleanLastVisitedMRU (void);
1.1.1.10 root 187: void ClearHistory (HWND hwndDlgItem);
1.1.1.6 root 188: LRESULT ListItemAdd (HWND list, int index, char *string);
189: LRESULT ListItemAddW (HWND list, int index, wchar_t *string);
190: LRESULT ListSubItemSet (HWND list, int index, int subIndex, char *string);
191: LRESULT ListSubItemSetW (HWND list, int index, int subIndex, wchar_t *string);
192: BOOL GetMountList (MOUNT_LIST_STRUCT *list);
193: int GetDriverRefCount ();
194: void GetSizeString (unsigned __int64 size, wchar_t *str);
195: char *LoadFile (char *fileName, DWORD *size);
1.1.1.10 root 196: char *GetModPath (char *path, int maxSize);
1.1.1.6 root 197: char *GetConfigPath (char *fileName);
198: void OpenPageHelp (HWND hwndDlg, int nPage);
199: int Info (char *stringId);
200: int Warning (char *stringId);
201: int Error (char *stringId);
202: int AskYesNo (char *stringId);
203: int AskNoYes (char *stringId);
204: int AskWarnYesNo (char *stringId);
205: int AskWarnNoYes (char *stringId);
1.1.1.11! root 206: int AskWarnNoYesString (wchar_t *string);
1.1.1.6 root 207: int AskWarnCancelOk (char *stringId);
1.1.1.10 root 208: int AskMultiChoice (void *strings[]);
1.1.1.6 root 209: BOOL ConfigWriteBegin ();
210: BOOL ConfigWriteEnd ();
211: BOOL ConfigWriteString (char *configKey, char *configValue);
212: BOOL ConfigWriteInt (char *configKey, int configValue);
213: int ConfigReadInt (char *configKey, int defaultValue);
214: char *ConfigReadString (char *configKey, char *defaultValue, char *str, int maxLen);
215: void RestoreDefaultKeyFilesParam (void);
216: BOOL LoadDefaultKeyFilesParam (void);
217: void Debug (char *format, ...);
218: void DebugMsgBox (char *format, ...);
219: BOOL Is64BitOs ();
1.1.1.10 root 220: void Applink (char *dest, BOOL bSendOS, char *extraOutput);
1.1.1.6 root 221: char *RelativePath2Absolute (char *szFileName);
222: void CheckSystemAutoMount ();
223: BOOL CALLBACK CloseTCWindowsEnum( HWND hwnd, LPARAM lParam);
1.1.1.7 root 224: BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam);
1.1.1.6 root 225: BYTE *MapResource (char *resourceType, int resourceId, PDWORD size);
1.1.1.8 root 226: BOOL SelectMultipleFiles (HWND hwndDlg, char *stringId, char *lpszFileName, BOOL keepHistory);
227: BOOL SelectMultipleFilesNext (char *lpszFileName);
1.1.1.9 root 228: void OpenOnlineHelp ();
1.1.1.10 root 229: BOOL GetPartitionInfo (char *deviceName, PPARTITION_INFORMATION rpartInfo);
230: BOOL GetDriveGeometry (char *deviceName, PDISK_GEOMETRY diskGeometry);
231: BOOL IsVolumeDeviceHosted (char *lpszDiskFile);
1.1.1.11! root 232: int CompensateXDPI (int val);
! 233: int CompensateYDPI (int val);
! 234: int CompensateDPIFont (int val);
1.1.1.10 root 235: int GetTextGfxWidth (HWND hwndDlgItem, wchar_t *text, HFONT hFont);
236: int GetTextGfxHeight (HWND hwndDlgItem, wchar_t *text, HFONT hFont);
237: BOOL ToHyperlink (HWND hwndDlg, UINT ctrlId);
1.1.1.11! root 238: void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate);
1.1.1.10 root 239: BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize);
240:
241: #ifdef __cplusplus
242: }
243: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.