other-licenses/7zstub/src/Windows/COM.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 // Windows/COM.h
michael@0 2
michael@0 3 #ifndef __WINDOWS_COM_H
michael@0 4 #define __WINDOWS_COM_H
michael@0 5
michael@0 6 #include "Common/String.h"
michael@0 7
michael@0 8 namespace NWindows {
michael@0 9 namespace NCOM {
michael@0 10
michael@0 11 class CComInitializer
michael@0 12 {
michael@0 13 public:
michael@0 14 CComInitializer() { CoInitialize(NULL);};
michael@0 15 ~CComInitializer() { CoUninitialize(); };
michael@0 16 };
michael@0 17
michael@0 18 class CStgMedium
michael@0 19 {
michael@0 20 STGMEDIUM _object;
michael@0 21 public:
michael@0 22 bool _mustBeReleased;
michael@0 23 CStgMedium(): _mustBeReleased(false) {}
michael@0 24 ~CStgMedium() { Free(); }
michael@0 25 void Free()
michael@0 26 {
michael@0 27 if(_mustBeReleased)
michael@0 28 ReleaseStgMedium(&_object);
michael@0 29 _mustBeReleased = false;
michael@0 30 }
michael@0 31 const STGMEDIUM* operator->() const { return &_object;}
michael@0 32 STGMEDIUM* operator->() { return &_object;}
michael@0 33 STGMEDIUM* operator&() { return &_object; }
michael@0 34 };
michael@0 35
michael@0 36 //////////////////////////////////
michael@0 37 // GUID <--> String Conversions
michael@0 38 UString GUIDToStringW(REFGUID guid);
michael@0 39 AString GUIDToStringA(REFGUID guid);
michael@0 40 #ifdef UNICODE
michael@0 41 #define GUIDToString GUIDToStringW
michael@0 42 #else
michael@0 43 #define GUIDToString GUIDToStringA
michael@0 44 #endif // !UNICODE
michael@0 45
michael@0 46 HRESULT StringToGUIDW(const wchar_t *string, GUID &classID);
michael@0 47 HRESULT StringToGUIDA(const char *string, GUID &classID);
michael@0 48 #ifdef UNICODE
michael@0 49 #define StringToGUID StringToGUIDW
michael@0 50 #else
michael@0 51 #define StringToGUID StringToGUIDA
michael@0 52 #endif // !UNICODE
michael@0 53
michael@0 54
michael@0 55 }}
michael@0 56
michael@0 57 #endif

mercurial