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