diff --git a/ntoskrnl/ex/init.c b/ntoskrnl/ex/init.c index e2413349cac..826cc3b3565 100644 --- a/ntoskrnl/ex/init.c +++ b/ntoskrnl/ex/init.c @@ -1589,7 +1589,7 @@ Phase1InitializationDiscard(IN PVOID Context) sizeof(InitBuffer->VersionBuffer), NT_SUCCESS(MsgStatus) ? (PCHAR)MsgEntry->Text : - "%u System Processor [%u MB Memory] %Z\r\n", + "%u System Processor [%Iu MB Memory] %Z\r\n", KeNumberProcessors, Size, &TempString); diff --git a/ntoskrnl/include/internal/amd64/mm.h b/ntoskrnl/include/internal/amd64/mm.h index 7d339a1b712..f7880944582 100644 --- a/ntoskrnl/include/internal/amd64/mm.h +++ b/ntoskrnl/include/internal/amd64/mm.h @@ -258,8 +258,6 @@ MI_MAKE_SUBSECTION_PTE( _Out_ PMMPTE NewPte, _In_ PVOID Segment) { - ULONG_PTR Offset; - /* Mark this as a prototype */ NewPte->u.Long = 0; NewPte->u.Subsect.Prototype = 1; diff --git a/ntoskrnl/include/internal/ex.h b/ntoskrnl/include/internal/ex.h index 740bb965645..a8e715aadda 100644 --- a/ntoskrnl/include/internal/ex.h +++ b/ntoskrnl/include/internal/ex.h @@ -1478,5 +1478,8 @@ XIPInit( #define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \ (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand)) +#define InterlockedCompareExchangeSizeT(Destination, Exchange, Comperand) \ + (SIZE_T)InterlockedCompareExchangePointer((PVOID*)(Destination), (PVOID)(SIZE_T)(Exchange), (PVOID)(SIZE_T)(Comperand)) + #define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \ (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand)) diff --git a/ntoskrnl/ob/obhandle.c b/ntoskrnl/ob/obhandle.c index 58e7ba3cd71..d753a68fad6 100644 --- a/ntoskrnl/ob/obhandle.c +++ b/ntoskrnl/ob/obhandle.c @@ -118,7 +118,7 @@ ObpReferenceProcessObjectByHandle(IN HANDLE Handle, /* Reference ourselves */ ObjectHeader = OBJECT_TO_OBJECT_HEADER(Process); - InterlockedIncrement(&ObjectHeader->PointerCount); + InterlockedIncrementSizeT(&ObjectHeader->PointerCount); /* Return the pointer */ *Object = Process; @@ -135,7 +135,7 @@ ObpReferenceProcessObjectByHandle(IN HANDLE Handle, /* Reference ourselves */ ObjectHeader = OBJECT_TO_OBJECT_HEADER(Thread); - InterlockedExchangeAdd(&ObjectHeader->PointerCount, 1); + InterlockedIncrementSizeT(&ObjectHeader->PointerCount); /* No audit mask */ *AuditMask = 0; @@ -188,7 +188,7 @@ ObpReferenceProcessObjectByHandle(IN HANDLE Handle, *Object = &ObjectHeader->Body; /* Add a reference */ - InterlockedExchangeAdd(&ObjectHeader->PointerCount, 1); + InterlockedIncrementSizeT(&ObjectHeader->PointerCount); /* Unlock the handle */ ExUnlockHandleTableEntry(HandleTable, HandleEntry); @@ -556,7 +556,7 @@ ObpDecrementHandleCount(IN PVOID ObjectBody, ProcessHandleCount = 0; /* Decrement the handle count */ - NewCount = InterlockedDecrement(&ObjectHeader->HandleCount); + NewCount = InterlockedDecrementSizeT(&ObjectHeader->HandleCount); /* Check if we're out of handles and this was an exclusive object */ if (!(NewCount) && (ObjectHeader->Flags & OB_FLAG_EXCLUSIVE)) @@ -964,7 +964,7 @@ ObpIncrementHandleCount(IN PVOID Object, } /* Increase the handle count */ - InterlockedIncrement(&ObjectHeader->HandleCount); + InterlockedIncrementSizeT(&ObjectHeader->HandleCount); ProcessHandleCount = 0; /* Check if we have a handle database */ @@ -1191,7 +1191,7 @@ ObpIncrementUnnamedHandleCount(IN PVOID Object, } /* Increase the handle count */ - InterlockedIncrement(&ObjectHeader->HandleCount); + InterlockedIncrementSizeT(&ObjectHeader->HandleCount); ProcessHandleCount = 0; /* Check if we have a handle database */ @@ -1386,8 +1386,8 @@ ObpCreateUnnamedHandle(IN PVOID Object, if (AdditionalReferences) { /* Add them to the header */ - InterlockedExchangeAdd(&ObjectHeader->PointerCount, - AdditionalReferences); + InterlockedExchangeAddSizeT(&ObjectHeader->PointerCount, + AdditionalReferences); } /* Save the access mask */ @@ -1437,8 +1437,8 @@ ObpCreateUnnamedHandle(IN PVOID Object, if (AdditionalReferences) { /* Dereference it as many times as required */ - InterlockedExchangeAdd(&ObjectHeader->PointerCount, - -(LONG)AdditionalReferences); + InterlockedExchangeAddSizeT(&ObjectHeader->PointerCount, + -(LONG)AdditionalReferences); } /* Decrement the handle count and detach */ @@ -1603,7 +1603,8 @@ ObpCreateHandle(IN OB_OPEN_REASON OpenReason, if (AdditionalReferences) { /* Add them to the header */ - InterlockedExchangeAdd(&ObjectHeader->PointerCount, AdditionalReferences); + InterlockedExchangeAddSizeT(&ObjectHeader->PointerCount, + AdditionalReferences); } /* Now we can release the object */ @@ -1692,8 +1693,8 @@ ObpCreateHandle(IN OB_OPEN_REASON OpenReason, if (AdditionalReferences > 1) { /* Dereference it many times */ - InterlockedExchangeAdd(&ObjectHeader->PointerCount, - -(LONG)(AdditionalReferences - 1)); + InterlockedExchangeAddSizeT(&ObjectHeader->PointerCount, + -(LONG)(AdditionalReferences - 1)); } /* Dereference the object one last time */ @@ -1972,7 +1973,7 @@ ObpDuplicateHandleCallback(IN PEPROCESS Process, ObjectHeader = ObpGetHandleObject(HandleTableEntry); /* Increment the pointer count */ - InterlockedIncrement(&ObjectHeader->PointerCount); + InterlockedIncrementSizeT(&ObjectHeader->PointerCount); /* Release the handle lock */ ExUnlockHandleTableEntry(HandleTable, OldEntry); diff --git a/ntoskrnl/ob/obname.c b/ntoskrnl/ob/obname.c index 849c79124b9..32e48941f7e 100644 --- a/ntoskrnl/ob/obname.c +++ b/ntoskrnl/ob/obname.c @@ -834,7 +834,7 @@ ReparseObject: Directory = NULL; /* Increment the pointer count */ - InterlockedExchangeAdd(&ObjectHeader->PointerCount, 1); + InterlockedExchangeAddSizeT(&ObjectHeader->PointerCount, 1); /* Cleanup from the first lookup */ ObpReleaseLookupContext(LookupContext); diff --git a/ntoskrnl/ob/obref.c b/ntoskrnl/ob/obref.c index 2f4da201499..d6b29d343bb 100644 --- a/ntoskrnl/ob/obref.c +++ b/ntoskrnl/ob/obref.c @@ -24,7 +24,7 @@ FASTCALL ObReferenceObjectSafe(IN PVOID Object) { POBJECT_HEADER ObjectHeader; - LONG OldValue, NewValue; + LONG_PTR OldValue, NewValue; /* Get the object header */ ObjectHeader = OBJECT_TO_OBJECT_HEADER(Object); @@ -37,9 +37,9 @@ ObReferenceObjectSafe(IN PVOID Object) do { /* Increase the reference count */ - NewValue = InterlockedCompareExchange(&ObjectHeader->PointerCount, - OldValue + 1, - OldValue); + NewValue = InterlockedCompareExchangeSizeT(&ObjectHeader->PointerCount, + OldValue + 1, + OldValue); if (OldValue == NewValue) return TRUE; /* Keep looping */ @@ -80,9 +80,9 @@ ObReferenceObjectEx(IN PVOID Object, IN LONG Count) { /* Increment the reference count and return the count now */ - return InterlockedExchangeAdd(&OBJECT_TO_OBJECT_HEADER(Object)-> - PointerCount, - Count) + Count; + return InterlockedExchangeAddSizeT(&OBJECT_TO_OBJECT_HEADER(Object)-> + PointerCount, + Count) + Count; } LONG @@ -91,13 +91,13 @@ ObDereferenceObjectEx(IN PVOID Object, IN LONG Count) { POBJECT_HEADER Header; - LONG NewCount; + LONG_PTR NewCount; /* Extract the object header */ Header = OBJECT_TO_OBJECT_HEADER(Object); /* Check whether the object can now be deleted. */ - NewCount = InterlockedExchangeAdd(&Header->PointerCount, -Count) - Count; + NewCount = InterlockedExchangeAddSizeT(&Header->PointerCount, -Count) - Count; if (!NewCount) ObpDeferObjectDeletion(Header); /* Return the current count */ @@ -274,7 +274,7 @@ ObReferenceFileObjectForWrite(IN HANDLE Handle, /* FIXME: Audit access if required */ /* Reference the object directly since we have its header */ - InterlockedIncrement(&ObjectHeader->PointerCount); + InterlockedIncrementSizeT(&ObjectHeader->PointerCount); /* Unlock the handle */ ExUnlockHandleTableEntry(HandleTable, HandleEntry); @@ -312,7 +312,7 @@ ObfReferenceObject(IN PVOID Object) ASSERT(Object); /* Get the header and increment the reference count */ - return InterlockedIncrement(&OBJECT_TO_OBJECT_HEADER(Object)->PointerCount); + return InterlockedIncrementSizeT(&OBJECT_TO_OBJECT_HEADER(Object)->PointerCount); } LONG_PTR @@ -332,7 +332,7 @@ ObfDereferenceObject(IN PVOID Object) } /* Check whether the object can now be deleted. */ - OldCount = InterlockedDecrement(&Header->PointerCount); + OldCount = InterlockedDecrementSizeT(&Header->PointerCount); if (!OldCount) { /* Sanity check */ @@ -362,7 +362,7 @@ ObDereferenceObjectDeferDelete(IN PVOID Object) POBJECT_HEADER Header = OBJECT_TO_OBJECT_HEADER(Object); /* Check whether the object can now be deleted. */ - if (!InterlockedDecrement(&Header->PointerCount)) + if (!InterlockedDecrementSizeT(&Header->PointerCount)) { /* Add us to the deferred deletion list */ ObpDeferObjectDeletion(Header); @@ -402,7 +402,7 @@ ObReferenceObjectByPointer(IN PVOID Object, } /* Increment the reference count and return success */ - InterlockedIncrement(&Header->PointerCount); + InterlockedIncrementSizeT(&Header->PointerCount); return STATUS_SUCCESS; } @@ -543,7 +543,7 @@ ObReferenceObjectByHandle(IN HANDLE Handle, /* Reference ourselves */ ObjectHeader = OBJECT_TO_OBJECT_HEADER(CurrentProcess); - InterlockedExchangeAdd(&ObjectHeader->PointerCount, 1); + InterlockedExchangeAddSizeT(&ObjectHeader->PointerCount, 1); /* Return the pointer */ *Object = CurrentProcess; @@ -591,7 +591,7 @@ ObReferenceObjectByHandle(IN HANDLE Handle, /* Reference ourselves */ ObjectHeader = OBJECT_TO_OBJECT_HEADER(CurrentThread); - InterlockedExchangeAdd(&ObjectHeader->PointerCount, 1); + InterlockedExchangeAddSizeT(&ObjectHeader->PointerCount, 1); /* Return the pointer */ *Object = CurrentThread; @@ -654,7 +654,7 @@ ObReferenceObjectByHandle(IN HANDLE Handle, !(~GrantedAccess & DesiredAccess)) { /* Reference the object directly since we have its header */ - InterlockedIncrement(&ObjectHeader->PointerCount); + InterlockedIncrementSizeT(&ObjectHeader->PointerCount); /* Mask out the internal attributes */ Attributes = HandleEntry->ObAttributes & OBJ_HANDLE_ATTRIBUTES; diff --git a/ntoskrnl/ob/obwait.c b/ntoskrnl/ob/obwait.c index 99e5a56701a..ff9cb2107f9 100644 --- a/ntoskrnl/ob/obwait.c +++ b/ntoskrnl/ob/obwait.c @@ -201,7 +201,7 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount, if (IsPointerOffset(DefaultObject)) { /* Increase reference count */ - InterlockedIncrement(&ObjectHeader->PointerCount); + InterlockedIncrementSizeT(&ObjectHeader->PointerCount); ReferencedObjects++; /* Save the Object and Wait Object, this is a relative offset */