1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 // ===========================================================================
8 // ===========================================================================
13 // A collection of utility macros.
19 #define COM_METHOD HRESULT STDMETHODCALLTYPE
21 inline HRESULT HrFromWin32(DWORD dwWin32Error)
23 return HRESULT_FROM_WIN32(dwWin32Error);
26 // Some helper #def's to safely Release, close & delete Objects under
41 #include "debugmacros.h"
43 // Good for verifying params withing range.
45 #define IfFalseGo(expr, HR) IfFailGo((expr) ? S_OK : (HR))
47 // ----------------------------------------------------------------------------
49 // Note that the Win32 APIs like IsBadReadPtr are banned
51 #define IsValidReadPtr(ptr, type) ((ptr)!=NULL)
53 #define IsValidWritePtr(ptr, type) ((ptr)!=NULL)
55 #define IsValidReadBufferPtr(ptr, type, len) ((ptr)!=NULL)
57 #define IsValidWriteBufferPtr(ptr, type, len) ((ptr)!=NULL)
59 #define IsValidInterfacePtr(ptr, type) ((ptr)!=NULL)
61 #define IsValidCodePtr(ptr) ((ptr)!=NULL)
63 #define IsValidStringPtr(ptr) ((ptr)!=NULL)
65 #define IsValidIID(iid) TRUE
67 #define IsValidCLSID(clsid) TRUE