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.

72 lines
3.1 KiB

  1. #define IsValidPtrIn(pv,cb) (!IsBadReadPtr ((pv),(cb)))
  2. #define IsValidPtrOut(pv,cb) (!IsBadWritePtr((pv),(cb)))
  3. STDAPI_(BOOL) IsValidInterface( void FAR* pv );
  4. STDAPI_(BOOL) IsValidIid( REFIID riid );
  5. #ifdef _DEBUG
  6. //** POINTER IN validation macros:
  7. #define VDATEPTRIN( pv, TYPE ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) \
  8. return (FnAssert(#pv,"Invalid in ptr", _szAssertFile, __LINE__),ResultFromScode(E_INVALIDARG))
  9. #define GEN_VDATEPTRIN( pv, TYPE, retval ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) \
  10. return (FnAssert(#pv,"Invalid in ptr", _szAssertFile, __LINE__), retval)
  11. #define VOID_VDATEPTRIN( pv, TYPE ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) {\
  12. FnAssert(#pv,"Invalid in ptr", _szAssertFile, __LINE__); return; }
  13. //** POINTER OUT validation macros:
  14. #define VDATEPTROUT( pv, TYPE ) if (!IsValidPtrOut( (pv), sizeof(TYPE))) \
  15. return (FnAssert(#pv,"Invalid out ptr", _szAssertFile, __LINE__),ResultFromScode(E_INVALIDARG))
  16. #define GEN_VDATEPTROUT( pv, TYPE, retval ) if (!IsValidPtrOut( (pv), sizeof(TYPE))) \
  17. return (FnAssert(#pv,"Invalid out ptr", _szAssertFile, __LINE__), retval)
  18. //** INTERFACE validation macro:
  19. #define GEN_VDATEIFACE( pv, retval ) if (!IsValidInterface(pv)) \
  20. return (FnAssert(#pv,"Invalid interface", _szAssertFile, __LINE__), retval)
  21. #define VDATEIFACE( pv ) if (!IsValidInterface(pv)) \
  22. return (FnAssert(#pv,"Invalid interface", _szAssertFile, __LINE__),ResultFromScode(E_INVALIDARG))
  23. #define VOID_VDATEIFACE( pv ) if (!IsValidInterface(pv)) {\
  24. FnAssert(#pv,"Invalid interface", _szAssertFile, __LINE__); return; }
  25. //** INTERFACE ID validation macro:
  26. #define VDATEIID( iid ) if (!IsValidIid( iid )) \
  27. return (FnAssert(#iid,"Invalid iid", _szAssertFile, __LINE__),ResultFromScode(E_INVALIDARG))
  28. #define GEN_VDATEIID( iid, retval ) if (!IsValidIid( iid )) {\
  29. FnAssert(#iid,"Invalid iid", _szAssertFile, __LINE__); return retval; }
  30. #else
  31. // --assertless macros for non-debug case
  32. //** POINTER IN validation macros:
  33. #define VDATEPTRIN( pv, TYPE ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) \
  34. return (ResultFromScode(E_INVALIDARG))
  35. #define GEN_VDATEPTRIN( pv, TYPE, retval ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) \
  36. return (retval)
  37. #define VOID_VDATEPTRIN( pv, TYPE ) if (!IsValidPtrIn( (pv), sizeof(TYPE))) {\
  38. return; }
  39. //** POINTER OUT validation macros:
  40. #define VDATEPTROUT( pv, TYPE ) if (!IsValidPtrOut( (pv), sizeof(TYPE))) \
  41. return (ResultFromScode(E_INVALIDARG))
  42. #define GEN_VDATEPTROUT( pv, TYPE, retval ) if (!IsValidPtrOut( (pv), sizeof(TYPE))) \
  43. return (retval)
  44. //** INTERFACE validation macro:
  45. #define VDATEIFACE( pv ) if (!IsValidInterface(pv)) \
  46. return (ResultFromScode(E_INVALIDARG))
  47. #define VOID_VDATEIFACE( pv ) if (!IsValidInterface(pv)) \
  48. return;
  49. #define GEN_VDATEIFACE( pv, retval ) if (!IsValidInterface(pv)) \
  50. return (retval)
  51. //** INTERFACE ID validation macro:
  52. #define VDATEIID( iid ) if (!IsValidIid( iid )) \
  53. return (ResultFromScode(E_INVALIDARG))
  54. #define GEN_VDATEIID( iid, retval ) if (!IsValidIid( iid )) \
  55. return retval;
  56. #endif