Annotation of truecrypt/setup/comsetup.cpp, revision 1.1.1.10

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>
                     16: #include <statreg.h>
                     17: #include <windows.h>
                     18: #include "ComSetup.h"
                     19: #include "Resource.h"
                     20: #include "../Mount/MainCom_i.c"
                     21: #include "../Format/FormatCom_i.c"
                     22: 
                     23: 
                     24: extern "C" BOOL RegisterComServers (char *modulePath)
                     25: {
                     26:        BOOL ret = FALSE;
                     27:        wchar_t mainModule[1024], formatModule[1024];
                     28:        CComPtr<ITypeLib> tl, tl2;
                     29: 
                     30:        wsprintfW (mainModule, L"%hsTrueCrypt.exe", modulePath);
                     31:        wsprintfW (formatModule, L"%hsTrueCrypt Format.exe", modulePath);
                     32: 
1.1.1.10! root       33:        UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32);
        !            34:        UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32);
1.1       root       35: 
                     36:        CRegObject ro;
                     37:        ro.FinalConstruct ();
                     38: 
                     39:        ro.AddReplacement (L"MAIN_MODULE", mainModule);
                     40:        ro.AddReplacement (L"FORMAT_MODULE", formatModule);
                     41: 
                     42:        wchar_t setupModule[MAX_PATH];
1.1.1.4   root       43:        GetModuleFileNameW (NULL, setupModule, sizeof (setupModule) / sizeof (setupModule[0]));
1.1       root       44:        if (ro.ResourceRegister (setupModule, IDR_COMREG, L"REGISTRY") != S_OK)
                     45:                goto error;
                     46: 
                     47:        if (LoadTypeLib (mainModule, &tl) != S_OK
                     48:                || RegisterTypeLib (tl, mainModule, 0) != S_OK)
                     49:                goto error;
                     50: 
                     51:        if (LoadTypeLib (formatModule, &tl2) != S_OK
                     52:                || RegisterTypeLib (tl2, formatModule, 0) != S_OK)
                     53:                goto error;
                     54: 
                     55:        ret = TRUE;
                     56: error:
                     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: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.