From 14a477026d6c9f3a549ba0dcc07955a8c70becfb Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 27 Nov 2019 00:13:25 +0100 Subject: Windows: compatibility with multi-OS boot configuration by only setting VeraCrypt as first bootloader of the system if the current first bootloader is Windows one. --- src/Common/Dlgcode.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/Common/Dlgcode.c') diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 376a1b29..c84e94ac 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -12685,19 +12685,16 @@ void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors) ShellExecuteW (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", cmdPath, param, NULL, SW_SHOW); } - -BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str) +BOOL BufferContainsPattern (const byte *buffer, size_t bufferSize, const byte *pattern, size_t patternSize) { - size_t strLen = strlen (str); - - if (bufferSize < strLen) + if (bufferSize < patternSize) return FALSE; - bufferSize -= strLen; + bufferSize -= patternSize; for (size_t i = 0; i < bufferSize; ++i) { - if (memcmp (buffer + i, str, strLen) == 0) + if (memcmp (buffer + i, pattern, patternSize) == 0) return TRUE; } @@ -12705,6 +12702,17 @@ BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *st } +BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str) +{ + return BufferContainsPattern (buffer, bufferSize, (const byte*) str, strlen (str)); +} + +BOOL BufferContainsWideString (const byte *buffer, size_t bufferSize, const wchar_t *str) +{ + return BufferContainsPattern (buffer, bufferSize, (const byte*) str, 2 * wcslen (str)); +} + + #ifndef SETUP int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL *pbDecrypt) -- cgit v1.2.3