|
|
1.1 root 1: /*
1.1.1.10 root 2: Copyright (c) 2007-2010 TrueCrypt Developers Association. All rights reserved.
1.1 root 3:
1.1.1.10 root 4: Governed by the TrueCrypt License 3.0 the full text of which is contained in
1.1.1.9 root 5: the file License.txt included in TrueCrypt binary and source code distribution
6: packages.
1.1 root 7: */
8:
1.1.1.10 root 9: #define TC_MAIN_COM_VERSION_MAJOR 2
10: #define TC_MAIN_COM_VERSION_MINOR 4
11:
12: #define TC_FORMAT_COM_VERSION_MAJOR 2
13: #define TC_FORMAT_COM_VERSION_MINOR 4
14:
1.1 root 15: #include <atlbase.h>
1.1.1.11! root 16: #include <comdef.h>
1.1 root 17: #include <statreg.h>
18: #include <windows.h>
19: #include "ComSetup.h"
1.1.1.11! root 20: #include "Dlgcode.h"
1.1 root 21: #include "Resource.h"
22: #include "../Mount/MainCom_i.c"
23: #include "../Format/FormatCom_i.c"
24:
25:
26: extern "C" BOOL RegisterComServers (char *modulePath)
27: {
1.1.1.11! root 28: BOOL ret = TRUE;
1.1 root 29: wchar_t mainModule[1024], formatModule[1024];
30: CComPtr<ITypeLib> tl, tl2;
31:
32: wsprintfW (mainModule, L"%hsTrueCrypt.exe", modulePath);
33: wsprintfW (formatModule, L"%hsTrueCrypt Format.exe", modulePath);
34:
1.1.1.10 root 35: UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32);
36: UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32);
1.1 root 37:
38: wchar_t setupModule[MAX_PATH];
1.1.1.4 root 39: GetModuleFileNameW (NULL, setupModule, sizeof (setupModule) / sizeof (setupModule[0]));
1.1 root 40:
1.1.1.11! root 41: CRegObject ro;
! 42: HRESULT r;
! 43:
! 44: if (!SUCCEEDED (r = ro.FinalConstruct ())
! 45: || !SUCCEEDED (r = ro.AddReplacement (L"MAIN_MODULE", mainModule))
! 46: || !SUCCEEDED (r = ro.AddReplacement (L"FORMAT_MODULE", formatModule))
! 47: || !SUCCEEDED (r = ro.ResourceRegister (setupModule, IDR_COMREG, L"REGISTRY"))
! 48: || !SUCCEEDED (r = LoadTypeLib (mainModule, &tl))
! 49: || !SUCCEEDED (r = RegisterTypeLib (tl, mainModule, 0))
! 50: || !SUCCEEDED (r = LoadTypeLib (formatModule, &tl2))
! 51: || !SUCCEEDED (r = RegisterTypeLib (tl2, formatModule, 0)))
! 52: {
! 53: MessageBox (MainDlg, _com_error (r).ErrorMessage(), TC_APP_NAME, MB_ICONERROR);
! 54: ret = FALSE;
! 55: }
1.1 root 56:
57: ro.FinalRelease ();
58: return ret;
59: }
60:
61:
62: extern "C" BOOL UnregisterComServers (char *modulePath)
63: {
64: BOOL ret;
65:
1.1.1.10 root 66: if (UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32) != S_OK)
1.1 root 67: return FALSE;
1.1.1.10 root 68: if (UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32) != S_OK)
1.1 root 69: return FALSE;
70:
71: wchar_t module[1024];
72: CRegObject ro;
73: ro.FinalConstruct ();
74:
1.1.1.3 root 75: wsprintfW (module, L"%hsTrueCrypt.exe", modulePath);
1.1 root 76: ro.AddReplacement (L"MAIN_MODULE", module);
77:
1.1.1.3 root 78: wsprintfW (module, L"%hsTrueCrypt Format.exe", modulePath);
1.1 root 79: ro.AddReplacement (L"FORMAT_MODULE", module);
80:
81: wchar_t setupModule[MAX_PATH];
1.1.1.4 root 82: GetModuleFileNameW (NULL, setupModule, sizeof (setupModule) / sizeof (setupModule[0]));
1.1 root 83:
84: ret = ro.ResourceUnregister (setupModule, IDR_COMREG, L"REGISTRY") == S_OK;
85:
86: ro.FinalRelease ();
87: return ret;
88: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.