From 6119fdaad408cff1b765010858f8e1d575c4aea8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 9 Jan 2012 21:55:56 +0000 Subject: [PATCH] [PSDK/DDK] - Add MAX_NATURAL_ALIGNMENT, MEMORY_ALLOCATION_ALIGNMENT and PROBE_ALIGNMENT defintions to ntdef.h - disable prefast warnings about banned api usage, dpc access and seh filter expression - annotate string types (PSTR, etc) as _Null_terminated_ svn path=/trunk/; revision=54891 --- reactos/include/crt/stdio.h | 12 ++++++++- reactos/include/ddk/ntstrsafe.h | 14 +++++++++- reactos/include/ddk/wdm.h | 7 +++++ reactos/include/psdk/ntdef.h | 48 ++++++++++++++++++++++----------- reactos/include/xdk/iofuncs.h | 7 +++++ 5 files changed, 70 insertions(+), 18 deletions(-) diff --git a/reactos/include/crt/stdio.h b/reactos/include/crt/stdio.h index c056dce6c42..aa78b2d3f65 100644 --- a/reactos/include/crt/stdio.h +++ b/reactos/include/crt/stdio.h @@ -300,7 +300,17 @@ extern "C" { _CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest,size_t _Count,const wchar_t *_Format,va_list _Args); #ifndef __NO_ISOCEXT /* externs in libmingwex.a */ _CRTIMP int __cdecl snwprintf (wchar_t* s, size_t n, const wchar_t* format, ...); - __CRT_INLINE int __cdecl vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, va_list arg) { return _vsnwprintf(s,n,format,arg); } + __CRT_INLINE int __cdecl vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, va_list arg) + { +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:28719) /* disable banned api usage warning */ +#endif /* _MSC_VER */ + return _vsnwprintf(s,n,format,arg); +#ifdef _MSC_VER +#pragma warning(pop) +#endif /* _MSC_VER */ + } _CRTIMP int __cdecl vwscanf (const wchar_t *, va_list); _CRTIMP int __cdecl vfwscanf (FILE *,const wchar_t *,va_list); _CRTIMP int __cdecl vswscanf (const wchar_t *,const wchar_t *,va_list); diff --git a/reactos/include/ddk/ntstrsafe.h b/reactos/include/ddk/ntstrsafe.h index d34b8896814..6b539a687cf 100644 --- a/reactos/include/ddk/ntstrsafe.h +++ b/reactos/include/ddk/ntstrsafe.h @@ -10,6 +10,11 @@ #include #include +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:28719) /* disable banned api usage warning */ +#endif /* _MSC_VER */ + #ifndef C_ASSERT #ifdef _MSC_VER # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] @@ -2062,4 +2067,11 @@ NTSTRSAFEAPI RtlStringLengthWorkerW(STRSAFE_LPCWSTR psz,size_t cchMax,size_t *pc #define RtlStringLengthWorkerA RtlStringLengthWorkerA_instead_use_StringCchLengthA_or_StringCbLengthA; #define RtlStringLengthWorkerW RtlStringLengthWorkerW_instead_use_StringCchLengthW_or_StringCbLengthW; -#endif +#ifdef _MSC_VER +#pragma warning(pop) +#ifdef _PREFAST_ +#pragma prefast(pop) +#endif /* _PREFAST_ */ +#endif /* _MSC_VER */ + +#endif /* _NTSTRSAFE_H_INCLUDED_ */ diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 7da5fa02093..663dda6f335 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -13027,9 +13027,16 @@ IoInitializeThreadedDpcRequest( IN PDEVICE_OBJECT DeviceObject, IN PIO_DPC_ROUTINE DpcRoutine) { +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:28128) +#endif KeInitializeThreadedDpc(&DeviceObject->Dpc, (PKDEFERRED_ROUTINE) DpcRoutine, DeviceObject ); +#ifdef _MSC_VER +#pragma warning(pop) +#endif } #endif diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index 8b578a9a827..9d99ccbe203 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -26,6 +26,7 @@ #include #include #include +#include // FIXME: Shouldn't be included! #include @@ -167,13 +168,20 @@ #define UNALIGNED64 #endif +#if defined(_WIN64) || defined(_M_ALPHA) +#define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG) +#define MEMORY_ALLOCATION_ALIGNMENT 16 +#else +#define MAX_NATURAL_ALIGNMENT sizeof(ULONG) +#define MEMORY_ALLOCATION_ALIGNMENT 8 +#endif + #if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED) #define RESTRICTED_POINTER __restrict #else #define RESTRICTED_POINTER #endif - #define ARGUMENT_PRESENT(ArgumentPointer) \ ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL) @@ -197,6 +205,14 @@ #define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test) #endif +#if defined(_AMD64_) || defined(_X86_) +#define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(ULONG) +#elif defined(_IA64_) || defined(_ARM_) +#define PROBE_ALIGNMENT(_s) max((TYPE_ALIGNMENT(_s), TYPE_ALIGNMENT(ULONG)) +#else +#error "unknown architecture" +#endif + /* Calling Conventions */ #if defined(_M_IX86) #define FASTCALL __fastcall @@ -358,11 +374,11 @@ typedef LONGLONG USN; /* ANSI (Multi-byte Character) types */ typedef CHAR *PCHAR, *LPCH, *PCH; typedef CONST CHAR *LPCCH, *PCCH; -typedef CHAR *NPSTR, *LPSTR, *PSTR; -typedef PSTR *PZPSTR; -typedef CONST PSTR *PCZPSTR; -typedef CONST CHAR *LPCSTR, *PCSTR; -typedef PCSTR *PZPCSTR; +typedef _Null_terminated_ CHAR *NPSTR, *LPSTR, *PSTR; +typedef _Null_terminated_ PSTR *PZPSTR; +typedef _Null_terminated_ CONST PSTR *PCZPSTR; +typedef _Null_terminated_ CONST CHAR *LPCSTR, *PCSTR; +typedef _Null_terminated_ PCSTR *PZPCSTR; /* Pointer to an Asciiz string */ typedef CHAR *PSZ; @@ -372,13 +388,13 @@ typedef CONST char *PCSZ; typedef wchar_t WCHAR; typedef WCHAR *PWCHAR, *LPWCH, *PWCH; typedef CONST WCHAR *LPCWCH, *PCWCH; -typedef WCHAR *NWPSTR, *LPWSTR, *PWSTR; -typedef PWSTR *PZPWSTR; -typedef CONST PWSTR *PCZPWSTR; -typedef WCHAR UNALIGNED *LPUWSTR, *PUWSTR; -typedef CONST WCHAR *LPCWSTR, *PCWSTR; -typedef PCWSTR *PZPCWSTR; -typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR; +typedef _Null_terminated_ WCHAR *NWPSTR, *LPWSTR, *PWSTR; +typedef _Null_terminated_ PWSTR *PZPWSTR; +typedef _Null_terminated_ CONST PWSTR *PCZPWSTR; +typedef _Null_terminated_ WCHAR UNALIGNED *LPUWSTR, *PUWSTR; +typedef _Null_terminated_ CONST WCHAR *LPCWSTR, *PCWSTR; +typedef _Null_terminated_ PCWSTR *PZPCWSTR; +typedef _Null_terminated_ CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR; /* Cardinal Data Types */ typedef char CCHAR, *PCCHAR; @@ -488,8 +504,8 @@ typedef struct _STRING32 { USHORT Length; USHORT MaximumLength; ULONG Buffer; -} STRING32, *PSTRING32, - UNICODE_STRING32, *PUNICODE_STRING32, +} STRING32, *PSTRING32, + UNICODE_STRING32, *PUNICODE_STRING32, ANSI_STRING32, *PANSI_STRING32; typedef struct _STRING64 { @@ -497,7 +513,7 @@ typedef struct _STRING64 { USHORT MaximumLength; ULONGLONG Buffer; } STRING64, *PSTRING64, - UNICODE_STRING64, *PUNICODE_STRING64, + UNICODE_STRING64, *PUNICODE_STRING64, ANSI_STRING64, *PANSI_STRING64; /* LangID and NLS */ diff --git a/reactos/include/xdk/iofuncs.h b/reactos/include/xdk/iofuncs.h index 5116cd685e0..a8ac52ec878 100644 --- a/reactos/include/xdk/iofuncs.h +++ b/reactos/include/xdk/iofuncs.h @@ -2658,9 +2658,16 @@ IoInitializeThreadedDpcRequest( IN PDEVICE_OBJECT DeviceObject, IN PIO_DPC_ROUTINE DpcRoutine) { +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:28128) +#endif KeInitializeThreadedDpc(&DeviceObject->Dpc, (PKDEFERRED_ROUTINE) DpcRoutine, DeviceObject ); +#ifdef _MSC_VER +#pragma warning(pop) +#endif } #endif -- 2.17.1