Reactos

[ATL] Prohibit the use of AddRef/Release on objects inside CComPtr

This mimics what MS's CComPtr is doing:
https://learn.microsoft.com/en-us/cpp/atl/reference/ccomptrbase-class?view=msvc-170#operator_ptr
The reasoning behind this is that AddRef/Release is handled by the CComPtr,
so anyone calling that is most likely not using the CComPtr correct.

+9 -2
+9 -2
sdk/lib/atl/atlcomcli.h
··· 59 59 return HRESULT_FROM_WIN32(dwError); 60 60 } 61 61 62 + template <class T> 63 + class _NoAddRefReleaseOnCComPtr : public T 64 + { 65 + private: 66 + virtual ULONG STDMETHODCALLTYPE AddRef() = 0; 67 + virtual ULONG STDMETHODCALLTYPE Release() = 0; 68 + }; 62 69 63 70 template<class T> 64 71 class CComPtr ··· 173 180 return p; 174 181 } 175 182 176 - T *operator -> () 183 + _NoAddRefReleaseOnCComPtr<T> *operator -> () const 177 184 { 178 185 ATLASSERT(p != NULL); 179 - return p; 186 + return (_NoAddRefReleaseOnCComPtr<T> *)p; 180 187 } 181 188 }; 182 189