diff options
author | David Foerster <david.foerster@informatik.hu-berlin.de> | 2016-05-10 22:16:32 +0200 |
---|---|---|
committer | David Foerster <david.foerster@informatik.hu-berlin.de> | 2016-05-10 22:18:34 +0200 |
commit | 11716ed2dacbb104f8f59867fe66f2c0a6984291 (patch) | |
tree | 28aa448de2e790d0f40dc57799a55a9df12ee6fb /src/Setup/Setup.c | |
parent | 191075155835172e5596e191cf0679ff9022f0fd (diff) | |
download | VeraCrypt-11716ed2dacbb104f8f59867fe66f2c0a6984291.tar.gz VeraCrypt-11716ed2dacbb104f8f59867fe66f2c0a6984291.zip |
Remove trailing whitespace
Diffstat (limited to 'src/Setup/Setup.c')
-rw-r--r-- | src/Setup/Setup.c | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c index 899c1583..331b8ea4 100644 --- a/src/Setup/Setup.c +++ b/src/Setup/Setup.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -156,7 +156,7 @@ static void RecursiveSetOwner (HKEY hKey, PSECURITY_DESCRIPTOR pSD) { LSTATUS status = 0; DWORD dwIndex = 0, dwMaxNameLen = 0, dwNameLen = 0, numberSubKeys = 0; - HKEY hSubKey; + HKEY hSubKey; if ( (ERROR_SUCCESS == status) && (ERROR_SUCCESS == RegQueryInfoKey(hKey, NULL, NULL, NULL, &numberSubKeys, &dwMaxNameLen, NULL, NULL, NULL, NULL, NULL, NULL)) && (numberSubKeys >= 1) @@ -192,7 +192,7 @@ static void RecursiveSetDACL (HKEY hKey, const wchar_t* SubKeyName, PSECURITY_DE HKEY hSubKey; DWORD dwIndex = 0, dwMaxNameLen = 0, dwNameLen = 0, numberSubKeys = 0; LSTATUS status = RegOpenKeyExW(hKey, SubKeyName, 0, WRITE_DAC | KEY_READ /*| ACCESS_SYSTEM_SECURITY*/, &hSubKey); - if (status == ERROR_SUCCESS) + if (status == ERROR_SUCCESS) { status = RegSetKeySecurity (hSubKey, DACL_SECURITY_INFORMATION, pSD); if (status == ERROR_SUCCESS) @@ -235,16 +235,16 @@ static void AllowKeyAccess(HKEY Key,const wchar_t* SubKeyName) std::string sNewSD; RegResult = RegOpenKeyExW(Key, SubKeyName, 0, WRITE_OWNER | KEY_READ, &SvcKey); - if (RegResult==ERROR_SUCCESS) + if (RegResult==ERROR_SUCCESS) { - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token)) + if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token)) { - if (!GetTokenInformation(Token, TokenUser, pTokenUser, 0, &dwLength)) + if (!GetTokenInformation(Token, TokenUser, pTokenUser, 0, &dwLength)) { - if (GetLastError() ==ERROR_INSUFFICIENT_BUFFER) + if (GetLastError() ==ERROR_INSUFFICIENT_BUFFER) { pTokenUser = (PTOKEN_USER) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength); - if (pTokenUser) + if (pTokenUser) { if (GetTokenInformation(Token, TokenUser, pTokenUser, dwLength, &dwLength)) { @@ -257,7 +257,7 @@ static void AllowKeyAccess(HKEY Key,const wchar_t* SubKeyName) RecursiveSetOwner(SvcKey, &SecDesc); } } - + } } } @@ -265,7 +265,7 @@ static void AllowKeyAccess(HKEY Key,const wchar_t* SubKeyName) RegCloseKey(SvcKey); } - if (pTokenUser) + if (pTokenUser) { PSID pSid = pTokenUser->User.Sid; DWORD dwAclSize = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + ::GetLengthSid(pSid) - sizeof(DWORD); @@ -338,7 +338,7 @@ void SearchAndDeleteRegistrySubString (HKEY hKey, const wchar_t *subKey, const w } for (std::list<std::wstring>::iterator ItSubKey = subKeysList.begin(); ItSubKey != subKeysList.end(); ItSubKey++) - { + { // if the string to search for is empty, delete the sub key, otherwise, look for matching value and delete them if (subStringLength == 0) { @@ -378,13 +378,13 @@ void SearchAndDeleteRegistrySubString (HKEY hKey, const wchar_t *subKey, const w foundEntries.push_back(szNameValue); } } - } while ((status == ERROR_SUCCESS) || (status == ERROR_MORE_DATA)); // we ignore ERROR_MORE_DATA errors since + } while ((status == ERROR_SUCCESS) || (status == ERROR_MORE_DATA)); // we ignore ERROR_MORE_DATA errors since // we are sure to use the correct sizes // delete the entries if (!foundEntries.empty()) { - for (std::list<std::wstring>::iterator It = foundEntries.begin(); + for (std::list<std::wstring>::iterator It = foundEntries.begin(); It != foundEntries.end(); It++) { RegDeleteValueW (hSubKey, It->c_str()); @@ -403,18 +403,18 @@ void SearchAndDeleteRegistrySubString (HKEY hKey, const wchar_t *subKey, const w } /* Set the given privilege of the current process */ -BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable) +BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable) { TOKEN_PRIVILEGES tp; LUID luid; - HANDLE hProcessToken; + HANDLE hProcessToken; BOOL bStatus = FALSE; if ( OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hProcessToken) ) { - if ( LookupPrivilegeValue( + if ( LookupPrivilegeValue( NULL, szPrivilegeName, &luid ) ) @@ -426,11 +426,11 @@ BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable) // Enable the privilege bStatus = AdjustTokenPrivileges( - hProcessToken, - FALSE, - &tp, - sizeof(TOKEN_PRIVILEGES), - (PTOKEN_PRIVILEGES) NULL, + hProcessToken, + FALSE, + &tp, + sizeof(TOKEN_PRIVILEGES), + (PTOKEN_PRIVILEGES) NULL, (PDWORD) NULL); } @@ -522,7 +522,7 @@ BOOL IsSystemRestoreEnabled () wchar_t szRegPath[MAX_PATH]; GetRestorePointRegKeyName (szRegPath, sizeof (szRegPath)); if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, szRegPath, 0, KEY_READ | KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS) - { + { if (IsOSAtLeast (WIN_VISTA)) { if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"RPSessionInterval", NULL, NULL, (LPBYTE) &dwValue, &cbValue)) @@ -542,7 +542,7 @@ BOOL IsSystemRestoreEnabled () } } - + RegCloseKey (hKey); } @@ -569,7 +569,7 @@ void StatusMessage (HWND hwndDlg, char *stringId) SendMessageW (GetDlgItem (hwndDlg, IDC_LOG_WINDOW), LB_ADDSTRING, 0, (LPARAM) GetString (stringId)); - SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_SETTOPINDEX, + SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_SETTOPINDEX, SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_GETCOUNT, 0, 0) - 1, 0); } @@ -582,8 +582,8 @@ void StatusMessageParam (HWND hwndDlg, char *stringId, wchar_t *param) StringCbPrintfW (szTmp, sizeof(szTmp), L"%s %s", GetString (stringId), param); SendMessageW (GetDlgItem (hwndDlg, IDC_LOG_WINDOW), LB_ADDSTRING, 0, (LPARAM) szTmp); - - SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_SETTOPINDEX, + + SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_SETTOPINDEX, SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_GETCOUNT, 0, 0) - 1, 0); } @@ -807,11 +807,11 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir) // Find the correct decompressed file in memory for (fileNo = 0; fileNo < NBR_COMPRESSED_FILES; fileNo++) { - // Write the file (stored in memory) directly to the destination location + // Write the file (stored in memory) directly to the destination location // (there will be no temporary files). if (wmemcmp ( - curFileName, - Decompressed_Files[fileNo].fileName, + curFileName, + Decompressed_Files[fileNo].fileName, min (wcslen (curFileName), (size_t) Decompressed_Files[fileNo].fileNameLength)) == 0) { // Dump filter driver cannot be installed to SysWOW64 directory @@ -825,7 +825,7 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir) bResult = SaveBufferToFile ( (char *) Decompressed_Files[fileNo].fileContent, szTmp, - Decompressed_Files[fileNo].fileLength, + Decompressed_Files[fileNo].fileLength, FALSE, TRUE); @@ -876,8 +876,8 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir) bResult = CopyFile (szTmp, servicePath.c_str(), FALSE); } - if (bResult && Is64BitOs () - && FileExists (favoritesLegacyFile.c_str()) + if (bResult && Is64BitOs () + && FileExists (favoritesLegacyFile.c_str()) && !FileExists (favoritesFile.c_str())) { // copy the favorites XML file to the native system directory @@ -1013,7 +1013,7 @@ err: { WIN32_FIND_DATA f; HANDLE h; - + SetCurrentDirectory (SetupFilesDir); h = FindFirstFile (L"Language.*.xml", &f); @@ -1145,7 +1145,7 @@ BOOL DoRegInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bInstallType) StringCbCopyW (szTmp, sizeof(szTmp), L"VeraCryptVolume"); if (RegSetValueEx (hkey, L"", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; - + RegCloseKey (hkey); hkey = 0; @@ -1160,7 +1160,7 @@ BOOL DoRegInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bInstallType) 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_WOW64_32KEY, NULL, &hkey, &dw) != ERROR_SUCCESS) goto error; - /* IMPORTANT: IF YOU CHANGE THIS IN ANY WAY, REVISE AND UPDATE SetInstallationPath() ACCORDINGLY! */ + /* IMPORTANT: IF YOU CHANGE THIS IN ANY WAY, REVISE AND UPDATE SetInstallationPath() ACCORDINGLY! */ StringCbPrintfW (szTmp, sizeof(szTmp), L"\"%sVeraCrypt Setup.exe\" /u", szDir); if (RegSetValueEx (hkey, L"UninstallString", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; @@ -1176,7 +1176,7 @@ BOOL DoRegInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bInstallType) StringCbCopyW (szTmp, sizeof(szTmp), _T(VERSION_STRING)); if (RegSetValueEx (hkey, L"DisplayVersion", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; - + StringCbCopyW (szTmp, sizeof(szTmp), L"VeraCrypt"); if (RegSetValueEx (hkey, L"DisplayName", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; @@ -1200,7 +1200,7 @@ error: handleWin32Error (hwndDlg, SRC_POS); Error ("REG_INSTALL_FAILED", hwndDlg); } - + // Register COM servers for UAC if (IsOSAtLeast (WIN_VISTA)) { @@ -1239,7 +1239,7 @@ BOOL DoApplicationDataUninstall (HWND hwndDlg) StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_HISTORY); RemoveMessage (hwndDlg, path2); StatDeleteFile (path2, FALSE); - + // Delete configuration file StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_CONFIGURATION); RemoveMessage (hwndDlg, path2); @@ -1314,7 +1314,7 @@ BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated) RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\DefaultIcon"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume"); - + if (!bRemoveDeprecated) { HKEY hKey; @@ -1333,7 +1333,7 @@ BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated) SearchAndDeleteRegistrySubString (HKEY_USERS, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.hc", NULL, TRUE, NULL); SearchAndDeleteRegistrySubString (HKEY_USERS, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Compatibility Assistant\\Persisted", L"VeraCrypt", TRUE, NULL); SearchAndDeleteRegistrySubString (HKEY_USERS, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage\\NewShortcuts", L"VeraCrypt", TRUE, NULL); - + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SYSTEM", 0, KEY_ALL_ACCESS | WRITE_DAC | WRITE_OWNER, &hKey) == ERROR_SUCCESS) { SearchAndDeleteRegistrySubString (hKey, L"Enum\\Root\\LEGACY_VERACRYPT", NULL, TRUE, L"ControlSet"); @@ -1346,7 +1346,7 @@ BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated) SHChangeNotify (SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); } - + if (hAdvapiDll) FreeLibrary (hAdvapiDll); @@ -1623,7 +1623,7 @@ BOOL DoDriverUnload (HWND hwndDlg) EnumWindows (CloseTCWindowsEnum, (LPARAM) &TCWindowClosed); - if (TCWindowClosed) + if (TCWindowClosed) Sleep (2000); } @@ -1648,7 +1648,7 @@ BOOL DoDriverUnload (HWND hwndDlg) } else { - // Note that the driver may have already been unloaded during this session (e.g. retry after an error, etc.) so it is not + // Note that the driver may have already been unloaded during this session (e.g. retry after an error, etc.) so it is not // guaranteed that the user is installing VeraCrypt for the first time now (we also cannot know if the user has already // installed and used VeraCrypt on another system before). bPossiblyFirstTimeInstall = TRUE; @@ -1748,7 +1748,7 @@ BOOL DoShortcutsUninstall (HWND hwndDlg, wchar_t *szDestDir) RemoveMessage (hwndDlg, szTmp2); if (StatDeleteFile (szTmp2, FALSE) == FALSE) goto error; - + StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt User's Guide.lnk"); StatDeleteFile (szTmp2, FALSE); @@ -1950,7 +1950,7 @@ static void SetSystemRestorePoint (HWND hwndDlg, BOOL finalize) static STATEMGRSTATUS SMgrStatus; static BOOL failed = FALSE; static BOOL (__stdcall *_SRSetRestorePoint)(PRESTOREPOINTINFO, PSTATEMGRSTATUS); - + if (!SystemRestoreDll) return; _SRSetRestorePoint = (BOOL (__stdcall *)(PRESTOREPOINTINFO, PSTATEMGRSTATUS))GetProcAddress (SystemRestoreDll,"SRSetRestorePointW"); @@ -1970,7 +1970,7 @@ static void SetSystemRestorePoint (HWND hwndDlg, BOOL finalize) RestPtInfo.llSequenceNumber = 0; StringCbCopyW (RestPtInfo.szDescription, sizeof(RestPtInfo.szDescription), bUninstall ? L"VeraCrypt uninstallation" : L"VeraCrypt installation"); - if(!_SRSetRestorePoint (&RestPtInfo, &SMgrStatus)) + if(!_SRSetRestorePoint (&RestPtInfo, &SMgrStatus)) { StatusMessage (hwndDlg, "FAILED_SYS_RESTORE"); failed = TRUE; @@ -1981,7 +1981,7 @@ static void SetSystemRestorePoint (HWND hwndDlg, BOOL finalize) RestPtInfo.dwEventType = END_SYSTEM_CHANGE; RestPtInfo.llSequenceNumber = SMgrStatus.llSequenceNumber; - if(!_SRSetRestorePoint(&RestPtInfo, &SMgrStatus)) + if(!_SRSetRestorePoint(&RestPtInfo, &SMgrStatus)) { StatusMessage (hwndDlg, "FAILED_SYS_RESTORE"); } @@ -2145,12 +2145,12 @@ void DoInstall (void *arg) } UpdateProgressBarProc(12); - + if (bSystemRestore) SetSystemRestorePoint (hwndDlg, FALSE); UpdateProgressBarProc(48); - + if (bDisableSwapFiles && IsPagingFileActive (FALSE)) { @@ -2167,7 +2167,7 @@ void DoInstall (void *arg) // Remove deprecated DoServiceUninstall (hwndDlg, L"VeraCryptService"); - + UpdateProgressBarProc(55); if (!SystemEncryptionUpdate) @@ -2348,7 +2348,7 @@ void SetInstallationPath (HWND hwndDlg) { /* VeraCrypt is not installed or it wasn't possible to determine where it is installed. */ - // Default "Program Files" path. + // Default "Program Files" path. SHGetSpecialFolderLocation (hwndDlg, CSIDL_PROGRAM_FILES, &itemList); SHGetPathFromIDList (itemList, path); @@ -2545,7 +2545,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz { if (!VerifyPackageIntegrity()) { - // Package corrupted + // Package corrupted exit (1); } bDevm = FALSE; @@ -2598,7 +2598,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz { /* Create the main dialog for install */ - DialogBoxParamW (hInstance, MAKEINTRESOURCEW (IDD_INSTL_DLG), NULL, (DLGPROC) MainDialogProc, + DialogBoxParamW (hInstance, MAKEINTRESOURCEW (IDD_INSTL_DLG), NULL, (DLGPROC) MainDialogProc, (LPARAM)lpszCommandLine); } else |