added a macro IsKernelPointer() to test whether a pointer value points to the kernel address space. This is needed because on IA-64 the MSB is not necessarily set for pointers to the kernel address space.

svn path=/trunk/; revision=17474
This commit is contained in:
Thomas Bluemel 2005-08-22 13:38:30 +00:00
parent 27d68c7b2f
commit bd73d35e4d
2 changed files with 21 additions and 3 deletions

View file

@ -147,6 +147,24 @@ RtlReleaseCapturedUnicodeString(
#define ProbeForReadLargeInteger(Ptr) ((LARGE_INTEGER)ProbeForReadGenericType(&(Ptr)->QuadPart, LONGLONG, 0)) #define ProbeForReadLargeInteger(Ptr) ((LARGE_INTEGER)ProbeForReadGenericType(&(Ptr)->QuadPart, LONGLONG, 0))
#define ProbeForReadUlargeInteger(Ptr) ((ULARGE_INTEGER)ProbeForReadGenericType(&(Ptr)->QuadPart, ULONGLONG, 0)) #define ProbeForReadUlargeInteger(Ptr) ((ULARGE_INTEGER)ProbeForReadGenericType(&(Ptr)->QuadPart, ULONGLONG, 0))
/*
* Use IsKernelPointer to test whether a pointer points to the kernel address
* space
*/
#if defined(_X86_) || defined(_M_AMD64)
/* for x86 and x86-64 the MSB is 1 so we can simply test on that */
#define IsKernelPointer(Ptr) ((LONG_PTR)(Ptr) < 0)
#elif defined(_IA64_)
/* on Itanium if the 24 most significant bits are set, we're not dealing with
user mode pointers. */
#define IsKernelPointer(Ptr) (((ULONG_PTR)(Ptr) & 0xFFFFFF0000000000ULL) != 0)
#else
#error IsKernelPointer() needs to be defined for this architecture
#endif
#endif #endif
/* /*

View file

@ -149,7 +149,7 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount,
DefaultObject = ObjectHeader->Type->DefaultObject; DefaultObject = ObjectHeader->Type->DefaultObject;
/* Check if it's the internal offset */ /* Check if it's the internal offset */
if ((LONG_PTR)DefaultObject >= 0) if (!IsKernelPointer(DefaultObject))
{ {
/* Increase reference count */ /* Increase reference count */
InterlockedIncrement(&ObjectHeader->PointerCount); InterlockedIncrement(&ObjectHeader->PointerCount);
@ -295,7 +295,7 @@ NtWaitForSingleObject(IN HANDLE ObjectHandle,
WaitableObject = BODY_TO_HEADER(Object)->Type->DefaultObject; WaitableObject = BODY_TO_HEADER(Object)->Type->DefaultObject;
/* Is it an offset for internal objects? */ /* Is it an offset for internal objects? */
if ((LONG_PTR)WaitableObject >= 0) if (!IsKernelPointer(WaitableObject))
{ {
/* Turn it into a pointer */ /* Turn it into a pointer */
WaitableObject = (PVOID)((ULONG_PTR)Object + WaitableObject = (PVOID)((ULONG_PTR)Object +
@ -389,7 +389,7 @@ NtSignalAndWaitForSingleObject(IN HANDLE ObjectHandleToSignal,
WaitableObject = BODY_TO_HEADER(WaitObj)->Type->DefaultObject; WaitableObject = BODY_TO_HEADER(WaitObj)->Type->DefaultObject;
/* Handle internal offset */ /* Handle internal offset */
if ((LONG_PTR)WaitableObject >= 0) if (!IsKernelPointer(WaitableObject))
{ {
/* Get real pointer */ /* Get real pointer */
WaitableObject = (PVOID)((ULONG_PTR)WaitObj + WaitableObject = (PVOID)((ULONG_PTR)WaitObj +