mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[misc] improve CoInitialize calls
* Balance with CoUninitialize and add COINIT_DISABLE_OLE1DDE * Also add /BREPRO linker flag for reproducible VS2019 release builds
This commit is contained in:
parent
2a3e82fa96
commit
2e1833e91e
8 changed files with 31 additions and 17 deletions
|
@ -245,6 +245,7 @@
|
|||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<AdditionalOptions>/BREPRO %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;RUFUS_LOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -271,6 +272,7 @@
|
|||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\arm</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/BREPRO %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;RUFUS_LOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -299,6 +301,7 @@
|
|||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\arm64</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/BREPRO %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;RUFUS_LOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -330,6 +333,7 @@
|
|||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
<AdditionalOptions>/BREPRO %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;RUFUS_LOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<Identity
|
||||
Name="19453.net.Rufus"
|
||||
Publisher="CN=7AC86D13-3E5A-491A-ADD5-80095C212740"
|
||||
Version="3.14.1769.0" />
|
||||
Version="3.14.1770.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Rufus</DisplayName>
|
||||
|
|
12
src/drive.c
12
src/drive.c
|
@ -458,7 +458,7 @@ BOOL RefreshLayout(DWORD DriveIndex)
|
|||
wnsprintf(wPhysicalName, ARRAYSIZE(wPhysicalName), L"\\\\?\\PhysicalDrive%lu", DriveIndex);
|
||||
|
||||
// Initialize COM
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
IGNORE_RETVAL(CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, 0, NULL));
|
||||
|
||||
|
@ -517,6 +517,7 @@ out:
|
|||
IVdsService_Release(pService);
|
||||
if (pLoader != NULL)
|
||||
IVdsServiceLoader_Release(pLoader);
|
||||
CoUninitialize();
|
||||
VDS_SET_ERROR(hr);
|
||||
return (hr == S_OK);
|
||||
}
|
||||
|
@ -541,7 +542,7 @@ static BOOL GetVdsDiskInterface(DWORD DriveIndex, const IID* InterfaceIID, void*
|
|||
wnsprintf(wPhysicalName, ARRAYSIZE(wPhysicalName), L"\\\\?\\PhysicalDrive%lu", DriveIndex);
|
||||
|
||||
// Initialize COM
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
IGNORE_RETVAL(CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, 0, NULL));
|
||||
|
||||
|
@ -673,6 +674,7 @@ static BOOL GetVdsDiskInterface(DWORD DriveIndex, const IID* InterfaceIID, void*
|
|||
IEnumVdsObject_Release(pEnum);
|
||||
|
||||
out:
|
||||
CoUninitialize();
|
||||
VDS_SET_ERROR(hr);
|
||||
return (hr == S_OK);
|
||||
}
|
||||
|
@ -689,7 +691,7 @@ BOOL VdsRescan(DWORD dwRescanType, DWORD dwSleepTime, BOOL bSilent)
|
|||
IVdsServiceLoader* pLoader;
|
||||
IVdsService* pService;
|
||||
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
IGNORE_RETVAL(CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, 0, NULL));
|
||||
|
||||
|
@ -739,6 +741,7 @@ BOOL VdsRescan(DWORD dwRescanType, DWORD dwSleepTime, BOOL bSilent)
|
|||
if (dwSleepTime != 0)
|
||||
Sleep(dwSleepTime);
|
||||
|
||||
CoUninitialize();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -806,7 +809,7 @@ BOOL ListVdsVolumes(BOOL bSilent)
|
|||
IUnknown* pUnk;
|
||||
|
||||
// Initialize COM
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
IGNORE_RETVAL(CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, 0, NULL));
|
||||
|
||||
|
@ -945,6 +948,7 @@ BOOL ListVdsVolumes(BOOL bSilent)
|
|||
IEnumVdsObject_Release(pEnum);
|
||||
|
||||
out:
|
||||
CoUninitialize();
|
||||
VDS_SET_ERROR(hr);
|
||||
return (hr == S_OK);
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ static BOOL FormatNativeVds(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Cl
|
|||
}
|
||||
|
||||
// Initialize COM
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
IGNORE_RETVAL(CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, 0, NULL));
|
||||
|
||||
|
@ -564,6 +564,7 @@ out:
|
|||
safe_free(wVolumeName);
|
||||
safe_free(wLabel);
|
||||
safe_free(wFSName);
|
||||
CoUninitialize();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
11
src/net.c
11
src/net.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Rufus: The Reliable USB Formatting Utility
|
||||
* Networking functionality (web file download, check for update, etc.)
|
||||
* Copyright © 2012-2019 Pete Batard <pete@akeo.ie>
|
||||
* Copyright © 2012-2021 Pete Batard <pete@akeo.ie>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -279,7 +279,7 @@ static HINTERNET GetInternetSession(BOOL bRetry)
|
|||
PF_INIT_OR_OUT(InternetSetOptionA, WinInet);
|
||||
|
||||
// Create a NetworkListManager Instance to check the network connection
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
hr = CoCreateInstance(&CLSID_NetworkListManager, NULL, CLSCTX_ALL,
|
||||
&IID_INetworkListManager, (LPVOID*)&pNetworkListManager);
|
||||
if (hr == S_OK) {
|
||||
|
@ -308,6 +308,7 @@ static HINTERNET GetInternetSession(BOOL bRetry)
|
|||
pfInternetSetOptionA(hSession, INTERNET_OPTION_ENABLE_HTTP_PROTOCOL, (LPVOID)&dwProtocolSupport, sizeof(dwProtocolSupport));
|
||||
|
||||
out:
|
||||
CoUninitialize();
|
||||
return hSession;
|
||||
}
|
||||
|
||||
|
@ -644,7 +645,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
|
|||
|
||||
verbose = ReadSetting32(SETTING_VERBOSE_UPDATES);
|
||||
// Without this the FileDialog will produce error 0x8001010E when compiled for Vista or later
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
// Unless the update was forced, wait a while before performing the update check
|
||||
if (!force_update_check) {
|
||||
// It would of course be a lot nicer to use a timer and wake the thread, but my
|
||||
|
@ -851,6 +852,7 @@ out:
|
|||
}
|
||||
force_update_check = FALSE;
|
||||
update_check_thread = NULL;
|
||||
CoUninitialize();
|
||||
ExitThread(0);
|
||||
}
|
||||
|
||||
|
@ -887,7 +889,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
|
|||
GUID guid;
|
||||
|
||||
dialog_showing++;
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
|
||||
// Use a GUID as random unique string, else ill-intentioned security "researchers"
|
||||
// may either spam our pipe or replace our script to fool antivirus solutions into
|
||||
|
@ -1047,6 +1049,7 @@ out:
|
|||
free(url);
|
||||
SendMessage(hMainDialog, UM_ENABLE_CONTROLS, 0, 0);
|
||||
dialog_showing--;
|
||||
CoUninitialize();
|
||||
ExitThread(dwExitCode);
|
||||
}
|
||||
|
||||
|
|
|
@ -3898,6 +3898,7 @@ out:
|
|||
for (i = 0; (!DeleteFileA(cmdline_hogger)) && (i <= 10); i++)
|
||||
Sleep(200);
|
||||
CloseHandle(mutex);
|
||||
CoUninitialize();
|
||||
CLOSE_OPENED_LIBRARIES;
|
||||
if (attached_console) {
|
||||
SetWindowPos(GetConsoleWindow(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_ACCEPTFILES
|
||||
CAPTION "Rufus 3.14.1769"
|
||||
CAPTION "Rufus 3.14.1770"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -395,8 +395,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,14,1769,0
|
||||
PRODUCTVERSION 3,14,1769,0
|
||||
FILEVERSION 3,14,1770,0
|
||||
PRODUCTVERSION 3,14,1770,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -414,13 +414,13 @@ BEGIN
|
|||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "3.14.1769"
|
||||
VALUE "FileVersion", "3.14.1770"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
VALUE "OriginalFilename", "rufus-3.14.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "3.14.1769"
|
||||
VALUE "ProductVersion", "3.14.1770"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Rufus: The Reliable USB Formatting Utility
|
||||
* Standard Windows function calls
|
||||
* Copyright © 2013-2019 Pete Batard <pete@akeo.ie>
|
||||
* Copyright © 2013-2021 Pete Batard <pete@akeo.ie>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -721,7 +721,7 @@ DWORD WINAPI SetLGPThread(LPVOID param)
|
|||
GUID snap_guid = { 0x3D271CFCL, 0x2BC6, 0x4AC2, {0xB6, 0x33, 0x3B, 0xDF, 0xF5, 0xBD, 0xAB, 0x2A} };
|
||||
|
||||
// Reinitialize COM since it's not shared between threads
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
||||
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
|
||||
// We need an IGroupPolicyObject instance to set a Local Group Policy
|
||||
hr = CoCreateInstance(&my_CLSID_GroupPolicyObject, NULL, CLSCTX_INPROC_SERVER, &my_IID_IGroupPolicyObject, (LPVOID*)&pLGPO);
|
||||
|
@ -797,6 +797,7 @@ error:
|
|||
RegCloseKey(path_key);
|
||||
if (pLGPO != NULL)
|
||||
pLGPO->lpVtbl->Release(pLGPO);
|
||||
CoUninitialize();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue