Author: cwittich Date: Mon Sep 7 08:37:11 2015 New Revision: 69081
URL: http://svn.reactos.org/svn/reactos?rev=69081&view=rev Log: [XDK][PSDK] add security checks for PSDK as well
Modified: trunk/reactos/include/psdk/ntdef.h trunk/reactos/include/psdk/winnt.h trunk/reactos/include/xdk/ntbasedef.h
Modified: trunk/reactos/include/psdk/ntdef.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntdef.h?rev=69... ============================================================================== --- trunk/reactos/include/psdk/ntdef.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/ntdef.h [iso-8859-1] Mon Sep 7 08:37:11 2015 @@ -768,8 +768,13 @@ #define RTL_NUMBER_OF_V2(A) \ (({ int _check_array_type[__builtin_types_compatible_p(typeof(A), typeof(&A[0])) ? -1 : 1]; (void)_check_array_type; }), \ RTL_NUMBER_OF_V1(A)) -#else - /// \todo implement security checks for cplusplus / MSVC +#elif defined(__cplusplus) +extern "C++" { + template <typename T, size_t N> + static char (& SAFE_RTL_NUMBER_OF(T (&)[N]))[N]; +} + #define RTL_NUMBER_OF_V2(A) sizeof(SAFE_RTL_NUMBER_OF(A)) +#else #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A) #endif
Modified: trunk/reactos/include/psdk/winnt.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winnt.h?rev=69... ============================================================================== --- trunk/reactos/include/psdk/winnt.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/winnt.h [iso-8859-1] Mon Sep 7 08:37:11 2015 @@ -702,8 +702,13 @@ #define RTL_NUMBER_OF_V2(A) \ (({ int _check_array_type[__builtin_types_compatible_p(typeof(A), typeof(&A[0])) ? -1 : 1]; (void)_check_array_type; }), \ RTL_NUMBER_OF_V1(A)) +#elif defined(__cplusplus) +extern "C++" { + template <typename T, size_t N> + static char (& SAFE_RTL_NUMBER_OF(T (&)[N]))[N]; +} + #define RTL_NUMBER_OF_V2(A) sizeof(SAFE_RTL_NUMBER_OF(A)) #else - /// \todo implement security checks for cplusplus / MSVC #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A) #endif
Modified: trunk/reactos/include/xdk/ntbasedef.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/xdk/ntbasedef.h?rev... ============================================================================== --- trunk/reactos/include/xdk/ntbasedef.h [iso-8859-1] (original) +++ trunk/reactos/include/xdk/ntbasedef.h [iso-8859-1] Mon Sep 7 08:37:11 2015 @@ -681,8 +681,10 @@ (({ int _check_array_type[__builtin_types_compatible_p(typeof(A), typeof(&A[0])) ? -1 : 1]; (void)_check_array_type; }), \ RTL_NUMBER_OF_V1(A)) #elif defined(__cplusplus) +extern "C++" { template <typename T, size_t N> - char (& SAFE_RTL_NUMBER_OF(T (&)[N]))[N]; + static char (& SAFE_RTL_NUMBER_OF(T (&)[N]))[N]; +} #define RTL_NUMBER_OF_V2(A) sizeof(SAFE_RTL_NUMBER_OF(A)) #else #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A)