1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-12 03:18:26 -06:00

Windows: solve installer issue on Windows 10 caused by failure to overwrite VeraCrypt driver file.

This commit is contained in:
Mounir IDRASSI
2015-06-09 23:29:33 +02:00
parent a7a8d57bca
commit b7eadfd310
6 changed files with 70 additions and 28 deletions

View File

@@ -297,7 +297,7 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
// Write the start marker
if (!SaveBufferToFile (MAG_START_MARKER, outputFile, strlen (MAG_START_MARKER), TRUE))
if (!SaveBufferToFile (MAG_START_MARKER, outputFile, strlen (MAG_START_MARKER), TRUE, FALSE))
{
if (remove (outputFile))
PkgError ("Cannot write the start marker\nFailed also to delete package file");
@@ -357,7 +357,7 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
// Write total size of the uncompressed data
szTmp32bitPtr = szTmp32bit;
mputLong (szTmp32bitPtr, (unsigned __int32) uncompressedDataLen);
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE, FALSE))
{
if (remove (outputFile))
PkgError ("Cannot write the total size of the uncompressed data.\nFailed also to delete package file");
@@ -394,7 +394,7 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
// Write the total size of the compressed data
szTmp32bitPtr = szTmp32bit;
mputLong (szTmp32bitPtr, (unsigned __int32) compressedDataLen);
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE, FALSE))
{
if (remove (outputFile))
PkgError ("Cannot write the total size of the compressed data.\nFailed also to delete package file");
@@ -404,7 +404,7 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
}
// Write the compressed data
if (!SaveBufferToFile (compressedBuffer, outputFile, compressedDataLen, TRUE))
if (!SaveBufferToFile (compressedBuffer, outputFile, compressedDataLen, TRUE, FALSE))
{
if (remove (outputFile))
PkgError ("Cannot write compressed data to the package.\nFailed also to delete package file");
@@ -414,7 +414,7 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
}
// Write the end marker
if (!SaveBufferToFile (MagEndMarker, outputFile, strlen (MagEndMarker), TRUE))
if (!SaveBufferToFile (MagEndMarker, outputFile, strlen (MagEndMarker), TRUE, FALSE))
{
if (remove (outputFile))
PkgError ("Cannot write the end marker.\nFailed also to delete package file");
@@ -450,7 +450,7 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
mputLong (szTmp32bitPtr, GetCrc32 (tmpBuffer, tmpFileSize));
free (tmpBuffer);
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE, FALSE))
{
if (remove (outputFile))
PkgError ("Cannot write the total size of the compressed data.\nFailed also to delete package file");
@@ -745,7 +745,7 @@ void __cdecl ExtractAllFilesThread (void *hwndDlg)
Decompressed_Files[fileNo].fileContent,
filePath,
Decompressed_Files[fileNo].fileLength,
FALSE))
FALSE, FALSE))
{
wchar_t szTmp[512];

View File

@@ -86,10 +86,20 @@ void localcleanup (void)
CloseAppSetupMutex ();
}
BOOL StatDeleteFile (char *lpszFile)
BOOL StatDeleteFile (char *lpszFile, BOOL bCheckForOldFile)
{
struct __stat64 st;
if (bCheckForOldFile)
{
char szOldPath[MAX_PATH + 1];
StringCbCopyA (szOldPath, sizeof(szOldPath), lpszFile);
StringCbCatA (szOldPath, sizeof(szOldPath), VC_FILENAME_RENAMED_SUFFIX);
if (_stat64 (szOldPath, &st) == 0)
DeleteFile (szOldPath);
}
if (_stat64 (lpszFile, &st) == 0)
return DeleteFile (lpszFile);
else
@@ -725,7 +735,8 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
(char *) Decompressed_Files[fileNo].fileContent,
szTmp,
Decompressed_Files[fileNo].fileLength,
FALSE);
FALSE,
TRUE);
if (driver64)
{
@@ -769,7 +780,7 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
}
else
{
bResult = StatDeleteFile (szTmp);
bResult = StatDeleteFile (szTmp, TRUE);
}
err:
@@ -1022,27 +1033,27 @@ BOOL DoApplicationDataUninstall (HWND hwndDlg)
// Delete favorite volumes file
StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_FAVORITE_VOLUMES);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2);
StatDeleteFile (path2, FALSE);
// Delete keyfile defaults
StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_DEFAULT_KEYFILES);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2);
StatDeleteFile (path2, FALSE);
// Delete history file
StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_HISTORY);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2);
StatDeleteFile (path2, FALSE);
// Delete configuration file
StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_CONFIGURATION);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2);
StatDeleteFile (path2, FALSE);
// Delete system encryption configuration file
StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_SYSTEM_ENCRYPTION);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2);
StatDeleteFile (path2, FALSE);
SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, 0, path);
StringCbCatA (path, sizeof(path), "\\VeraCrypt");
@@ -1491,22 +1502,22 @@ BOOL DoShortcutsUninstall (HWND hwndDlg, char *szDestDir)
// Start menu entries
StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt.lnk");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2) == FALSE)
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
goto error;
StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCryptExpander.lnk");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2) == FALSE)
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
goto error;
StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt Website.url");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2) == FALSE)
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
goto error;
StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\Uninstall VeraCrypt.lnk");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2) == FALSE)
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
goto error;
StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt User's Guide.lnk");
@@ -1527,7 +1538,7 @@ BOOL DoShortcutsUninstall (HWND hwndDlg, char *szDestDir)
StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt.lnk");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2) == FALSE)
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
goto error;
bOK = TRUE;

View File

@@ -123,7 +123,7 @@ static char *szCompressedFiles[]=
#define NBR_COMPRESSED_FILES (sizeof(szCompressedFiles) / sizeof(szCompressedFiles[0]))
void localcleanup (void);
BOOL StatDeleteFile ( char *lpszFile );
BOOL StatDeleteFile ( char *lpszFile, BOOL bCheckForOldFile );
BOOL StatRemoveDirectory ( char *lpszDir );
HRESULT CreateLink ( char *lpszPathObj , char *lpszArguments , char *lpszPathLink );
void GetProgramPath ( HWND hwndDlg , char *path );