From 7bc4256c420d1da2e51ac90dd913ea4307407299 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Thu, 2 Sep 2021 00:08:18 +0200 Subject: Windows MSI: Fix error querying bootloader information --- src/SetupDLL/Setup.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/SetupDLL/Setup.c b/src/SetupDLL/Setup.c index d6f5ebfd..cc537d23 100644 --- a/src/SetupDLL/Setup.c +++ b/src/SetupDLL/Setup.c @@ -1891,7 +1891,8 @@ BOOL UpgradeBootLoader_Dll (MSIHANDLE hInstaller, HWND hwndDlg) { MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin UpgradeBootLoader_Dll"); - BOOL bOK = FALSE; + BOOL bOK = FALSE, bNeedUnloadDriver = FALSE; + int status; if (!SystemEncryptionUpdate) { @@ -1900,6 +1901,19 @@ BOOL UpgradeBootLoader_Dll (MSIHANDLE hInstaller, HWND hwndDlg) goto end; } + if (hDriver == INVALID_HANDLE_VALUE) + { + status = DriverAttach(); + if ((status == 0) && (hDriver != INVALID_HANDLE_VALUE)) + { + bNeedUnloadDriver = TRUE; + } + else + { + MSILog(hInstaller, MSI_INFO_LEVEL, L"UpgradeBootLoader_Dll: failed to attach to driver"); + } + } + try { BootEncryption bootEnc (hwndDlg); @@ -1928,6 +1942,11 @@ BOOL UpgradeBootLoader_Dll (MSIHANDLE hInstaller, HWND hwndDlg) MSILog (hInstaller, MSI_ERROR_LEVEL, GetString("BOOT_LOADER_UPGRADE_FAILED")); end: + if (bNeedUnloadDriver) + { + CloseHandle (hDriver); + hDriver = INVALID_HANDLE_VALUE; + } MSILog(hInstaller, MSI_INFO_LEVEL, L"End UpgradeBootLoader_Dll"); return bOK; } -- cgit v1.2.3