Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.4 KiB

  1. //
  2. // WARNING: IsValidPtrIn and IsValidPtrOut are defined as macros
  3. // here. They are also defined as ISVALIDPTRIN and ISVALIDPTROUT
  4. // in compobj\valid.cxx, which are functions. The functions are
  5. // used to keep backward compatibility, while the macros are
  6. // smaller and faster to use.
  7. //
  8. #define IsValidPtrIn(pv,cb) (!IsBadReadPtr ((pv),(cb)))
  9. #define IsValidPtrOut(pv,cb) (!IsBadWritePtr((pv),(cb)))
  10. STDAPI_(BOOL) IsValidInterface( void FAR* pv );
  11. STDAPI_(BOOL) IsValidIid( REFIID riid );
  12. #ifdef _DEBUG
  13. //** POINTER IN validation macros:
  14. #define VDATEPTRIN( pv, TYPE ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) \
  15. return (FnAssert(#pv,"Invalid in ptr", _szAssertFile, __LINE__),ResultFromScode(E_INVALIDARG))
  16. #define GEN_VDATEPTRIN( pv, TYPE, retval ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) \
  17. return (FnAssert(#pv,"Invalid in ptr", _szAssertFile, __LINE__), retval)
  18. #define VOID_VDATEPTRIN( pv, TYPE ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) {\
  19. FnAssert(#pv,"Invalid in ptr", _szAssertFile, __LINE__); return; }
  20. //** POINTER OUT validation macros:
  21. #define VDATEPTROUT( pv, TYPE ) if (!IsValidPtrOut( (pv), sizeof(TYPE))) \
  22. return (FnAssert(#pv,"Invalid out ptr", _szAssertFile, __LINE__),ResultFromScode(E_INVALIDARG))
  23. #define GEN_VDATEPTROUT( pv, TYPE, retval ) if (!IsValidPtrOut( (pv), sizeof(TYPE))) \
  24. return (FnAssert(#pv,"Invalid out ptr", _szAssertFile, __LINE__), retval)
  25. //** INTERFACE validation macro:
  26. #define GEN_VDATEIFACE( pv, retval ) if (!IsValidInterface(pv)) \
  27. return (FnAssert(#pv,"Invalid interface", _szAssertFile, __LINE__), retval)
  28. #define VDATEIFACE( pv ) if (!IsValidInterface(pv)) \
  29. return (FnAssert(#pv,"Invalid interface", _szAssertFile, __LINE__),ResultFromScode(E_INVALIDARG))
  30. #define VOID_VDATEIFACE( pv ) if (!IsValidInterface(pv)) {\
  31. FnAssert(#pv,"Invalid interface", _szAssertFile, __LINE__); return; }
  32. //** INTERFACE ID validation macro:
  33. #define VDATEIID( iid ) if (!IsValidIid( iid )) \
  34. return (FnAssert(#iid,"Invalid iid", _szAssertFile, __LINE__),ResultFromScode(E_INVALIDARG))
  35. #define GEN_VDATEIID( iid, retval ) if (!IsValidIid( iid )) {\
  36. FnAssert(#iid,"Invalid iid", _szAssertFile, __LINE__); return retval; }
  37. #else
  38. // --assertless macros for non-debug case
  39. //** POINTER IN validation macros:
  40. #define VDATEPTRIN( pv, TYPE ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) \
  41. return (ResultFromScode(E_INVALIDARG))
  42. #define GEN_VDATEPTRIN( pv, TYPE, retval ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) \
  43. return (retval)
  44. #define VOID_VDATEPTRIN( pv, TYPE ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) {\
  45. return; }
  46. //** POINTER OUT validation macros:
  47. #define VDATEPTROUT( pv, TYPE ) if (!IsValidPtrOut( (pv), sizeof(TYPE))) \
  48. return (ResultFromScode(E_INVALIDARG))
  49. #define GEN_VDATEPTROUT( pv, TYPE, retval ) if (!IsValidPtrOut( (pv), sizeof(TYPE))) \
  50. return (retval)
  51. //** INTERFACE validation macro:
  52. #define VDATEIFACE( pv ) if (!IsValidInterface(pv)) \
  53. return (ResultFromScode(E_INVALIDARG))
  54. #define VOID_VDATEIFACE( pv ) if (!IsValidInterface(pv)) \
  55. return;
  56. #define GEN_VDATEIFACE( pv, retval ) if (!IsValidInterface(pv)) \
  57. return (retval)
  58. //** INTERFACE ID validation macro:
  59. #define VDATEIID( iid ) if (!IsValidIid( iid )) \
  60. return (ResultFromScode(E_INVALIDARG))
  61. #define GEN_VDATEIID( iid, retval ) if (!IsValidIid( iid )) \
  62. return retval;
  63. #endif