From 968a05bfe4deceaea5ba67b4fc8e9f6f4e36fa18 Mon Sep 17 00:00:00 2001 From: wj32 Date: Fri, 18 Nov 2011 09:58:09 +0000 Subject: [PATCH] applied some NT header fixes from 3.x git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4871 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- 2.x/trunk/phlib/include/ntbasic.h | 5 +++++ 2.x/trunk/phlib/include/ntrtl.h | 23 +++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/2.x/trunk/phlib/include/ntbasic.h b/2.x/trunk/phlib/include/ntbasic.h index e1d886d38..37d71a93a 100644 --- a/2.x/trunk/phlib/include/ntbasic.h +++ b/2.x/trunk/phlib/include/ntbasic.h @@ -113,6 +113,8 @@ typedef struct _UNICODE_STRING typedef const UNICODE_STRING *PCUNICODE_STRING; +#define RTL_CONSTANT_STRING(s) { sizeof(s) - sizeof((s)[0]), sizeof(s), s } + // Portability typedef struct _SINGLE_LIST_ENTRY32 @@ -173,6 +175,9 @@ typedef const OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; (p)->SecurityQualityOfService = NULL; \ } +#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a) { sizeof(OBJECT_ATTRIBUTES), NULL, n, a, NULL, NULL } +#define RTL_INIT_OBJECT_ATTRIBUTES(n, a) RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a) + // Portability typedef struct _OBJECT_ATTRIBUTES64 diff --git a/2.x/trunk/phlib/include/ntrtl.h b/2.x/trunk/phlib/include/ntrtl.h index eacfaa441..550d3f803 100644 --- a/2.x/trunk/phlib/include/ntrtl.h +++ b/2.x/trunk/phlib/include/ntrtl.h @@ -1195,7 +1195,7 @@ FORCEINLINE VOID RtlInitString( ) { if (SourceString) - DestinationString->MaximumLength = DestinationString->Length = (USHORT)strlen(SourceString); + DestinationString->MaximumLength = (DestinationString->Length = (USHORT)strlen(SourceString)) + 1; else DestinationString->MaximumLength = DestinationString->Length = 0; @@ -1218,7 +1218,7 @@ FORCEINLINE VOID RtlInitAnsiString( ) { if (SourceString) - DestinationString->MaximumLength = DestinationString->Length = (USHORT)strlen(SourceString); + DestinationString->MaximumLength = (DestinationString->Length = (USHORT)strlen(SourceString)) + 1; else DestinationString->MaximumLength = DestinationString->Length = 0; @@ -1328,9 +1328,8 @@ FORCEINLINE VOID RtlInitUnicodeString( __in_opt PWSTR SourceString ) { - // MaximumLength should really be Length + sizeof(WCHAR), but it doesn't matter too much. if (SourceString) - DestinationString->MaximumLength = DestinationString->Length = (USHORT)(wcslen(SourceString) * sizeof(WCHAR)); + DestinationString->MaximumLength = (DestinationString->Length = (USHORT)(wcslen(SourceString) * sizeof(WCHAR))) + sizeof(WCHAR); else DestinationString->MaximumLength = DestinationString->Length = 0; @@ -2579,9 +2578,9 @@ NTAPI RtlSetEnvironmentVar( __in_opt PWSTR *Environment, __in_ecount(NameLength) PWSTR Name, - __in ULONG NameLength, + __in SIZE_T NameLength, __in_ecount(ValueLength) PWSTR Value, - __in ULONG ValueLength + __in SIZE_T ValueLength ); #endif @@ -2602,10 +2601,10 @@ NTAPI RtlQueryEnvironmentVariable( __in_opt PVOID Environment, __in_ecount(NameLength) PWSTR Name, - __in ULONG NameLength, + __in SIZE_T NameLength, __out_ecount(ValueLength) PWSTR Value, - __in ULONG ValueLength, - __out PULONG ReturnLength + __in SIZE_T ValueLength, + __out PSIZE_T ReturnLength ); #endif @@ -2626,10 +2625,10 @@ NTAPI RtlExpandEnvironmentStrings( __in_opt PVOID Environment, __in_ecount(SrcLength) PWSTR Src, - __in ULONG SrcLength, + __in SIZE_T SrcLength, __out_ecount(DstLength) PWSTR Dst, - __in ULONG DstLength, - __out_opt PULONG ReturnLength + __in SIZE_T DstLength, + __out_opt PSIZE_T ReturnLength ); #endif