From 0bd265cbde32fde9814d7cabf8e99142ce94bba5 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 7 Sep 2015 01:35:23 +0200 Subject: Windows: Launch Format/Expander wizards from VeraCrypt.exe using executable binaries with the same architecture. --- src/Mount/Mount.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 97187f92..72728321 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -1288,10 +1288,25 @@ static void LaunchVolCreationWizard (HWND hwndDlg, const char *arg) { STARTUPINFO si; PROCESS_INFORMATION pi; + char formatExeName[64]; + char* suffix = NULL; ZeroMemory (&si, sizeof (si)); + StringCbCopyA (formatExeName, sizeof (formatExeName), "\\VeraCrypt Format"); + + // check if there is a suffix in VeraCrypt file name + // in order to use the same for "VeraCrypt Format" + suffix = strrchr (tmp + 1, '-'); + if (suffix) + { + StringCbCatA (formatExeName, sizeof (formatExeName), suffix); + StringCbCatA (formatExeName, sizeof (formatExeName), "\""); + } + else + StringCbCatA (formatExeName, sizeof (formatExeName), ".exe\""); + *tmp = 0; - StringCbCatA (t, sizeof(t), "\\VeraCrypt Format.exe\""); + StringCbCatA (t, sizeof(t), formatExeName); if (!FileExists(t)) Error ("VOL_CREATION_WIZARD_NOT_FOUND", hwndDlg); // Display a user-friendly error message and advise what to do @@ -1316,7 +1331,7 @@ static void LaunchVolCreationWizard (HWND hwndDlg, const char *arg) static void LaunchVolExpander (HWND hwndDlg) { - char t[TC_MAX_PATH] = {'"',0}; + char t[TC_MAX_PATH + TC_MAX_PATH] = {'"',0}; char *tmp; GetModuleFileName (NULL, t+1, sizeof(t)-1); @@ -1324,8 +1339,24 @@ static void LaunchVolExpander (HWND hwndDlg) tmp = strrchr (t, '\\'); if (tmp) { + char expanderExeName[64]; + char* suffix = NULL; + + StringCbCopyA (expanderExeName, sizeof (expanderExeName), "\\VeraCryptExpander"); + + // check if there is a suffix in VeraCrypt file name + // in order to use the same for "VeraCrypt Format" + suffix = strrchr (tmp + 1, '-'); + if (suffix) + { + StringCbCatA (expanderExeName, sizeof (expanderExeName), suffix); + StringCbCatA (expanderExeName, sizeof (expanderExeName), "\""); + } + else + StringCbCatA (expanderExeName, sizeof (expanderExeName), ".exe\""); + *tmp = 0; - StringCbCatA (t, sizeof(t), "\\VeraCryptExpander.exe\""); + StringCbCatA (t, sizeof(t), expanderExeName); if (!FileExists(t)) Error ("VOL_EXPANDER_NOT_FOUND", hwndDlg); // Display a user-friendly error message and advise what to do -- cgit v1.2.3