--- truecrypt/setup/comsetup.cpp 2018/04/24 17:06:37 1.1.1.9 +++ truecrypt/setup/comsetup.cpp 2018/04/24 17:11:40 1.1.1.11 @@ -1,15 +1,23 @@ /* - Copyright (c) 2007 TrueCrypt Developers Association. All rights reserved. + Copyright (c) 2007-2010 TrueCrypt Developers Association. All rights reserved. - Governed by the TrueCrypt License 2.8 the full text of which is contained in + Governed by the TrueCrypt License 3.0 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. */ +#define TC_MAIN_COM_VERSION_MAJOR 2 +#define TC_MAIN_COM_VERSION_MINOR 4 + +#define TC_FORMAT_COM_VERSION_MAJOR 2 +#define TC_FORMAT_COM_VERSION_MINOR 4 + #include +#include #include #include #include "ComSetup.h" +#include "Dlgcode.h" #include "Resource.h" #include "../Mount/MainCom_i.c" #include "../Format/FormatCom_i.c" @@ -17,37 +25,35 @@ extern "C" BOOL RegisterComServers (char *modulePath) { - BOOL ret = FALSE; + BOOL ret = TRUE; wchar_t mainModule[1024], formatModule[1024]; CComPtr tl, tl2; wsprintfW (mainModule, L"%hsTrueCrypt.exe", modulePath); wsprintfW (formatModule, L"%hsTrueCrypt Format.exe", modulePath); - UnRegisterTypeLib (LIBID_TrueCryptMainCom, 1, 0, 0, SYS_WIN32); - UnRegisterTypeLib (LIBID_TrueCryptFormatCom, 1, 0, 0, SYS_WIN32); - - CRegObject ro; - ro.FinalConstruct (); - - ro.AddReplacement (L"MAIN_MODULE", mainModule); - ro.AddReplacement (L"FORMAT_MODULE", formatModule); + UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32); + UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32); wchar_t setupModule[MAX_PATH]; GetModuleFileNameW (NULL, setupModule, sizeof (setupModule) / sizeof (setupModule[0])); - if (ro.ResourceRegister (setupModule, IDR_COMREG, L"REGISTRY") != S_OK) - goto error; - if (LoadTypeLib (mainModule, &tl) != S_OK - || RegisterTypeLib (tl, mainModule, 0) != S_OK) - goto error; - - if (LoadTypeLib (formatModule, &tl2) != S_OK - || RegisterTypeLib (tl2, formatModule, 0) != S_OK) - goto error; + CRegObject ro; + HRESULT r; + + if (!SUCCEEDED (r = ro.FinalConstruct ()) + || !SUCCEEDED (r = ro.AddReplacement (L"MAIN_MODULE", mainModule)) + || !SUCCEEDED (r = ro.AddReplacement (L"FORMAT_MODULE", formatModule)) + || !SUCCEEDED (r = ro.ResourceRegister (setupModule, IDR_COMREG, L"REGISTRY")) + || !SUCCEEDED (r = LoadTypeLib (mainModule, &tl)) + || !SUCCEEDED (r = RegisterTypeLib (tl, mainModule, 0)) + || !SUCCEEDED (r = LoadTypeLib (formatModule, &tl2)) + || !SUCCEEDED (r = RegisterTypeLib (tl2, formatModule, 0))) + { + MessageBox (MainDlg, _com_error (r).ErrorMessage(), TC_APP_NAME, MB_ICONERROR); + ret = FALSE; + } - ret = TRUE; -error: ro.FinalRelease (); return ret; } @@ -57,9 +63,9 @@ extern "C" BOOL UnregisterComServers (ch { BOOL ret; - if (UnRegisterTypeLib (LIBID_TrueCryptMainCom, 1, 0, 0, SYS_WIN32) != S_OK) + if (UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32) != S_OK) return FALSE; - if (UnRegisterTypeLib (LIBID_TrueCryptFormatCom, 1, 0, 0, SYS_WIN32) != S_OK) + if (UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32) != S_OK) return FALSE; wchar_t module[1024];