|
|
1.1 ! root 1: /* ! 2: Copyright (c) TrueCrypt Foundation. All rights reserved. ! 3: ! 4: Covered by the TrueCrypt License 2.2 the full text of which is contained ! 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: ! 27: UnRegisterTypeLib (LIBID_TrueCrypt, 1, 0, 0, SYS_WIN32); ! 28: UnRegisterTypeLib (LIBID_TrueCryptFormat, 1, 0, 0, SYS_WIN32); ! 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]; ! 37: GetModuleFileNameW (NULL, setupModule, sizeof (setupModule)); ! 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: ! 60: if (UnRegisterTypeLib (LIBID_TrueCrypt, 1, 0, 0, SYS_WIN32) != S_OK) ! 61: return FALSE; ! 62: if (UnRegisterTypeLib (LIBID_TrueCryptFormat, 1, 0, 0, SYS_WIN32) != S_OK) ! 63: return FALSE; ! 64: ! 65: wchar_t module[1024]; ! 66: CRegObject ro; ! 67: ro.FinalConstruct (); ! 68: ! 69: wsprintfW (module, L"%hs\\TrueCrypt.exe", modulePath); ! 70: ro.AddReplacement (L"MAIN_MODULE", module); ! 71: ! 72: wsprintfW (module, L"%hs\\TrueCrypt Format.exe", modulePath); ! 73: ro.AddReplacement (L"FORMAT_MODULE", module); ! 74: ! 75: wchar_t setupModule[MAX_PATH]; ! 76: GetModuleFileNameW (NULL, setupModule, sizeof (setupModule)); ! 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.