From ed1caccac78b1bdf2ff8262853d25eb7a61f5062 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 11 Dec 2015 11:16:09 +0530 Subject: [PATCH] Fix bundled Universal CRT not working on computers where the Universal CRT was not already installed --- setup/installer/windows/freeze.py | 19 +++++++++++-------- setup/installer/windows/main.c | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/setup/installer/windows/freeze.py b/setup/installer/windows/freeze.py index b20d2892e5..6983e0ffa4 100644 --- a/setup/installer/windows/freeze.py +++ b/setup/installer/windows/freeze.py @@ -730,14 +730,17 @@ class Win32Freeze(Command, WixMixIn): vc_path = os.path.join(r'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist', plat, 'Microsoft.VC140.CRT') if not os.path.exists(vc_path): raise SystemExit('Visual Studio redistributable CRT not found') - # I cannot get app local deployment of the UCRT to work. Things left to - # try: try dlls from the windows sdk standalone, try manually loading - # ucrtbase.dll and some api dlls before loading the launcher. - # sdk_path = os.path.join(r'C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs', plat) - # if not os.path.exists(sdk_path): - # raise SystemExit('Windows 10 redistributable CRT not found') - # for dll in glob.glob(os.path.join(sdk_path, '*.dll')): - # shutil.copy2(dll, self.dll_dir) + # We cannot use the Universal CRT DLLs that come with Visual Studio, as + # they are broken. Have to use the ones from the Standalone SDK for Windows 10. + # However, I dont want to install this SDK, incase it messes things up, + # so the below path points to dlls I got from installing the SDK in a + # different VM. To re-create just copy the api-ms*.dll and ucrtbase.dll + # files from a previous calibre install. + sdk_path = os.path.join(SW, '..', 'ucrt', 'DLLs', plat) + if not os.path.exists(sdk_path): + raise SystemExit('Windows 10 Universal CRT redistributable not found') + for dll in glob.glob(os.path.join(sdk_path, '*.dll')): + shutil.copy2(dll, self.dll_dir) for dll in glob.glob(os.path.join(vc_path, '*.dll')): bname = os.path.basename(dll) if not bname.startswith('vccorlib') and not bname.startswith('concrt'): diff --git a/setup/installer/windows/main.c b/setup/installer/windows/main.c index 126cffb823..7d9d4fe5f0 100644 --- a/setup/installer/windows/main.c +++ b/setup/installer/windows/main.c @@ -78,6 +78,8 @@ static ENTRYPROC load_launcher_dll() { show_last_error(L"Failed to set DLL directory"); return NULL; } + // Have to load ucrtbase manually first, otherwise loading fails on systems where the + // Universal CRT is not installed. if (!LoadLibraryW(L"ucrtbase.dll")) { show_last_error(L"Unable to find ucrtbase.dll. You should install all Windows updates on your computer to get this file."); return NULL;