Annotation of truecrypt/common/basecom.h, revision 1.1.1.5

1.1       root        1: /*
1.1.1.3   root        2:  Copyright (c) 2007-2008 TrueCrypt Foundation. All rights reserved.
1.1       root        3: 
1.1.1.5 ! root        4:  Governed by the TrueCrypt License 2.6 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: 
1.1.1.3   root        9: #ifndef TC_HEADER_BASE_COM
                     10: #define TC_HEADER_BASE_COM
                     11: 
1.1       root       12: #include <guiddef.h>
                     13: 
                     14: template <class TClass>
                     15: class TrueCryptFactory : public IClassFactory
                     16: {
                     17: 
                     18: public:
                     19:        TrueCryptFactory (DWORD messageThreadId) : 
                     20:                RefCount (1), ServerLockCount (0), MessageThreadId (messageThreadId) { }
                     21: 
                     22:        ~TrueCryptFactory () { }
                     23:        
                     24:        virtual ULONG STDMETHODCALLTYPE AddRef ()
                     25:        {
                     26:                return InterlockedIncrement (&RefCount) - 1;
                     27:        }
                     28: 
                     29:        virtual ULONG STDMETHODCALLTYPE Release ()
                     30:        {
                     31:                ULONG r = InterlockedDecrement (&RefCount) + 1;
                     32: 
                     33:                if (r == 0)
                     34:                        delete this;
                     35: 
                     36:                return r;
                     37:        }
                     38: 
                     39:        virtual HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void **ppvObject)
                     40:        {
                     41:                if (riid == IID_IUnknown || riid == IID_IClassFactory)
                     42:                        *ppvObject = this;
                     43:                else
                     44:                {
                     45:                        *ppvObject = NULL;
                     46:                        return E_NOINTERFACE;
                     47:                }
                     48: 
                     49:                AddRef ();
                     50:                return S_OK;
                     51:        }
                     52:         
                     53:        virtual HRESULT STDMETHODCALLTYPE CreateInstance (IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
                     54:        {
                     55:                if (pUnkOuter != NULL)
                     56:                        return CLASS_E_NOAGGREGATION;
                     57: 
                     58:                TClass *tc = new TClass (MessageThreadId);
                     59:                if (tc == NULL)
                     60:                        return E_OUTOFMEMORY;
                     61: 
                     62:                HRESULT hr = tc->QueryInterface (riid, ppvObject);
                     63: 
                     64:                if (hr)
                     65:                        delete tc;
                     66: 
                     67:                return hr;
                     68:        }
                     69: 
                     70:        virtual HRESULT STDMETHODCALLTYPE LockServer (BOOL fLock)
                     71:        {
                     72:                if (fLock)
                     73:                {
                     74:                        InterlockedIncrement (&ServerLockCount);
                     75:                }
                     76:                else
                     77:                {
                     78:                        if (!InterlockedDecrement (&ServerLockCount))
                     79:                                PostThreadMessage (MessageThreadId, WM_APP, 0, 0);
                     80:                }
                     81: 
                     82:                return S_OK;
                     83:        }
                     84: 
                     85:        virtual bool IsServerLocked ()
                     86:        {
                     87:                return ServerLockCount > 0;
                     88:        }
                     89: 
                     90: protected:
                     91:        DWORD MessageThreadId;
                     92:        LONG RefCount;
                     93:        LONG ServerLockCount;
                     94: };
                     95: 
                     96: 
1.1.1.3   root       97: class BaseCom
                     98: {
                     99: public:
                    100:        static DWORD CallDriver (DWORD ioctl, BSTR input, BSTR *output);
1.1.1.5 ! root      101:        static BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
1.1.1.3   root      102:        static DWORD ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone);
1.1.1.4   root      103:        static DWORD RegisterFilterDriver (BOOL registerDriver, BOOL volumeClass);
1.1.1.3   root      104:        static DWORD SetDriverServiceStartType (DWORD startType);
1.1.1.4   root      105:        static DWORD WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value);
1.1.1.3   root      106: };
                    107: 
                    108: 
1.1       root      109: BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer);
                    110: HRESULT CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv);
1.1.1.3   root      111: 
                    112: #endif // TC_HEADER_BASE_COM

unix.superglobalmegacorp.com

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