Author: tkreuzer Date: Wed Mar 25 22:27:44 2015 New Revision: 66886
URL: http://svn.reactos.org/svn/reactos?rev=66886&view=rev Log: [INCLUDE] - intsafe.h: Fix some constants to be C++ compatible - sal.h: Implement _Analysis_mode_, __prefast_operator_new_null and __prefast_operator_new_throws annotations - Make probe.h (mostly) C++ compatible
Modified: trunk/reactos/include/ndk/no_sal2.h trunk/reactos/include/psdk/driverspecs.h trunk/reactos/include/psdk/intsafe.h trunk/reactos/include/psdk/sal.h trunk/reactos/include/reactos/probe.h
Modified: trunk/reactos/include/ndk/no_sal2.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/no_sal2.h?rev=6... ============================================================================== --- trunk/reactos/include/ndk/no_sal2.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/no_sal2.h [iso-8859-1] Wed Mar 25 22:27:44 2015 @@ -5,6 +5,7 @@
/* From sal.h */ #define _Always_(annos) +#define _Analysis_mode_(mode) #define _Analysis_noreturn_ #define _Analysis_assume_(expr) __analysis_assume(expr) #define _At_(target, annos) @@ -664,6 +665,8 @@ #define _Kernel_requires_resource_not_held_(kind) #define _Kernel_acquires_resource_(kind) #define _Landmark_(name) +#define __prefast_operator_new_null +#define __prefast_operator_new_throws
/* concurrencysal.h */ #define _Benign_race_begin_ __pragma(warning(push))
Modified: trunk/reactos/include/psdk/driverspecs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/driverspecs.h?... ============================================================================== --- trunk/reactos/include/psdk/driverspecs.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/driverspecs.h [iso-8859-1] Wed Mar 25 22:27:44 2015 @@ -135,8 +135,14 @@ #define __internal_kernel_driver #define __kernel_code #define __kernel_driver -#define __prefast_operator_new_null -#define __prefast_operator_new_throws +#define __prefast_operator_new_null \ + void* __cdecl operator new(size_t size) throw(); \ + void* __cdecl operator new[](size_t size) throw(); \ + _Analysis_mode_(_Analysis_operator_new_null_) +#define __prefast_operator_new_throws \ + void* __cdecl operator new(size_t size) throw(std::bad_alloc); \ + void* __cdecl operator new[](size_t size) throw(std::bad_alloc); \ + _Analysis_mode_(_Analysis_operator_new_throw_) #define __user_code #define __user_driver #define ___drv_unit_internal_kernel_driver
Modified: trunk/reactos/include/psdk/intsafe.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/intsafe.h?rev=... ============================================================================== --- trunk/reactos/include/psdk/intsafe.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/intsafe.h [iso-8859-1] Wed Mar 25 22:27:44 2015 @@ -147,12 +147,12 @@
#define INT8_MAX ((signed char)127) #define UINT8_MAX ((unsigned char)0xffU) -#define BYTE_MAX 0xff -#define SHORT_MAX 32767 +#define BYTE_MAX ((unsigned char)0xff) +#define SHORT_MAX ((short)32767) #define INT16_MAX ((short)32767) -#define USHORT_MAX 0xffff -#define UINT16_MAX ((unsigned short)0xffffU) -#define WORD_MAX 0xffff +#define USHORT_MAX ((unsigned short)0xffff) +#define UINT16_MAX ((unsigned short)0xffff) +#define WORD_MAX ((unsigned short)0xffff) #define INT_MAX 2147483647 #define INT32_MAX 2147483647 #define UINT_MAX 0xffffffff @@ -196,15 +196,15 @@ /* Error values */ #define INT8_ERROR ((signed char)(-1)) #define UINT8_ERROR ((unsigned char)0xff) -#define BYTE_ERROR 0xff -#define SHORT_ERROR (-1) +#define BYTE_ERROR ((unsigned char)0xff) +#define SHORT_ERROR ((short)(-1)) #define INT16_ERROR ((short)(-1)) -#define USHORT_ERROR 0xffff -#define UINT16_ERROR ((unsigned short)0xffffU) -#define WORD_ERROR 0xffff +#define USHORT_ERROR ((unsigned short)0xffff) +#define UINT16_ERROR ((unsigned short)0xffff) +#define WORD_ERROR ((unsigned short)0xffff) #define INT_ERROR (-1) #define INT32_ERROR (-1) -#define UINT_ERROR 0xffffffff +#define UINT_ERROR 0xffffffffU #define UINT32_ERROR 0xffffffffU #define LONG_ERROR (-1L) #define ULONG_ERROR 0xffffffffUL @@ -228,25 +228,25 @@ #define _SIZE_T_ERROR 0xffffffffffffffffULL #else /* _WIN64 */ #define INT_PTR_ERROR (-1) -#define UINT_PTR_ERROR 0xffffffff +#define UINT_PTR_ERROR 0xffffffffU #define LONG_PTR_ERROR (-1L) #define ULONG_PTR_ERROR 0xffffffffUL #define DWORD_PTR_ERROR 0xffffffffUL #define PTRDIFF_T_ERROR (-1) -#define SIZE_T_ERROR 0xffffffff +#define SIZE_T_ERROR 0xffffffffU #define SSIZE_T_ERROR (-1L) #define _SIZE_T_ERROR 0xffffffffUL #endif /* _WIN64 */
/* special definitons (the CHAR ones should not be defined here!) */ #define _INTSAFE_CHAR CHAR -#define _INTSAFE_CHAR_ERROR 0xff +#define _INTSAFE_CHAR_ERROR ((signed char)(-1)) #ifdef _CHAR_UNSIGNED - #define _INTSAFE_CHAR_MIN 0 - #define _INTSAFE_CHAR_MAX 0xff + #define _INTSAFE_CHAR_MIN ((unsigned char)0) + #define _INTSAFE_CHAR_MAX ((unsigned char)0xff) #else - #define _INTSAFE_CHAR_MIN (-128) - #define _INTSAFE_CHAR_MAX 127 + #define _INTSAFE_CHAR_MIN ((signed char)(-128)) + #define _INTSAFE_CHAR_MAX ((signed char)127) #endif /* _CHAR_UNSIGNED */
#define size_t_ERROR SIZE_T_ERROR
Modified: trunk/reactos/include/psdk/sal.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/sal.h?rev=6688... ============================================================================== --- trunk/reactos/include/psdk/sal.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/sal.h [iso-8859-1] Wed Mar 25 22:27:44 2015 @@ -53,9 +53,12 @@ #error broken #endif // ]
-#pragma warning(disable:6320) /* disable warning about SEH filter */ -#pragma warning(disable:28247) /* duplicated model file annotations */ +#pragma warning(disable:6320) /* Disable warning about SEH filter */ +#pragma warning(disable:28247) /* Duplicated model file annotations */ #pragma warning(disable:28251) /* Inconsistent annotation */ +#ifndef _M_IX86 // [ +#pragma warning(disable:28110 28111 28161 28162) /* Floating point save */ +#endif // ]
/******************************************************************************/ //#include "codeanalysis\sourceannotations.h" @@ -420,6 +423,9 @@ #define _At_buffer_(target, iter, bound, annos) [SAL_at_buffer(p1=_SA_SPECSTRIZE(target), p2=_SA_SPECSTRIZE(iter), p3=_SA_SPECSTRIZE(bound))] [SAL_begin] annos [SAL_end] #define _On_failure_(annos) [SAL_context(p1="SAL_failed")] _Group_(_Post_ _Group_(annos)) #define _Always_(annos) _Group_(annos) _On_failure_(annos) + +#define _Analysis_mode_impl_(mode) _SAL2_NAME(_Analysis_mode_impl) _Group_([SAL_annotes(Name="SAL_analysisMode", p1=_SA_SPECSTRIZE(mode))]) +#define _Analysis_mode_(mode) typedef _Analysis_mode_impl_(mode) int __prefast_analysis_mode_flag__COUNTER__;
#define _Analysis_noreturn_ _SAL2_NAME(_Analysis_noreturn_) [SAL_annotes(Name="SAL_terminates")] #define _Analysis_assume_(expr) __assume(expr) @@ -1099,6 +1105,7 @@ #define __inner_exceptthat #define __inner_typefix(ctype) #define _Always_(annos) +#define _Analysis_mode_(mode) #define _Analysis_noreturn_ #define _Analysis_assume_(expr) ((void)0) #define __analysis_assume(expr) ((void)0)
Modified: trunk/reactos/include/reactos/probe.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/probe.h?rev... ============================================================================== --- trunk/reactos/include/reactos/probe.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/probe.h [iso-8859-1] Wed Mar 25 22:27:44 2015 @@ -12,7 +12,7 @@ static const ULARGE_INTEGER __emptyULargeInteger = {{0, 0}}; static const IO_STATUS_BLOCK __emptyIoStatusBlock = {{0}, 0};
-#if defined(_WIN32K_) +#if defined(_WIN32K_) && !defined(__cplusplus) static const LARGE_STRING __emptyLargeString = {0, 0, 0, NULL}; #endif
@@ -152,7 +152,12 @@ { _SEH2_TRY { +#ifdef __cplusplus + ProbeForRead(UnsafeSrc, sizeof(*UnsafeSrc), 1); + RtlCopyMemory(Dest, UnsafeSrc, sizeof(*UnsafeSrc)); +#else *Dest = ProbeForReadUnicodeString(UnsafeSrc); +#endif if(Dest->Buffer != NULL) { if (Dest->Length != 0) @@ -162,7 +167,7 @@ sizeof(WCHAR));
/* Allocate space for the buffer */ - Buffer = ExAllocatePoolWithTag(PagedPool, + Buffer = (PWCHAR)ExAllocatePoolWithTag(PagedPool, Dest->Length + sizeof(WCHAR), 'RTSU'); if (Buffer == NULL)