Author: tkreuzer
Date: Thu Jul 31 18:01:51 2008
New Revision: 34986
URL:
http://svn.reactos.org/svn/reactos?rev=34986&view=rev
Log:
- fix usage of InterlockedExchangePointer
- some ULONG / SIZE_T fixes
- pushlocks have a union with a PVOID and an ULONG, use them instead of typecasting
- use InterlockedAndPointer for a pushlock
Modified:
branches/ros-amd64-bringup/reactos/ntoskrnl/config/cmkcbncb.c
branches/ros-amd64-bringup/reactos/ntoskrnl/ex/handle.c
branches/ros-amd64-bringup/reactos/ntoskrnl/ex/init.c
branches/ros-amd64-bringup/reactos/ntoskrnl/ex/pushlock.c
branches/ros-amd64-bringup/reactos/ntoskrnl/kdbg/kdb.c
branches/ros-amd64-bringup/reactos/ntoskrnl/se/audit.c
branches/ros-amd64-bringup/reactos/ntoskrnl/se/lsa.c
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/config/cmkcbncb.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/config/cmkcbncb.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/config/cmkcbncb.c [iso-8859-1] Thu Jul 31
18:01:51 2008
@@ -903,7 +903,7 @@
for (i = 0; i < 4; i++)
{
/* Add it into the list */
- if (!InterlockedCompareExchangePointer(&KeyBody->KeyControlBlock->
+ if
(!InterlockedCompareExchangePointer((PVOID*)&KeyBody->KeyControlBlock->
KeyBodyArray[i],
KeyBody,
NULL))
@@ -959,7 +959,7 @@
for (i = 0; i < 4; i++)
{
/* Add it into the list */
- if (InterlockedCompareExchangePointer(&KeyBody->KeyControlBlock->
+ if
(InterlockedCompareExchangePointer((VOID*)&KeyBody->KeyControlBlock->
KeyBodyArray[i],
NULL,
KeyBody) == KeyBody)
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ex/handle.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ex/handle.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ex/handle.c [iso-8859-1] Thu Jul 31
18:01:51 2008
@@ -516,7 +516,7 @@
/* Write the new level and attempt to change the table code */
TableBase = ((ULONG_PTR)Mid) | 1;
- Value = InterlockedExchangePointer(&HandleTable->TableCode, TableBase);
+ Value = InterlockedExchangePointer((PVOID*)&HandleTable->TableCode,
(PVOID)TableBase);
}
else if (TableLevel == 1)
{
@@ -533,7 +533,7 @@
if (!Low) return FALSE;
/* Update the table */
- Value = InterlockedExchangePointer(&SecondLevel[i], Low);
+ Value = InterlockedExchangePointer((PVOID*)&SecondLevel[i], Low);
ASSERT(Value == NULL);
}
else
@@ -560,7 +560,7 @@
/* Write the new table and change the table code */
TableBase = ((ULONG_PTR)High) | 2;
- Value = InterlockedExchangePointer(&HandleTable->TableCode,
+ Value = InterlockedExchangePointer((PVOID*)&HandleTable->TableCode,
(PVOID)TableBase);
}
}
@@ -581,7 +581,7 @@
if (!Mid) return FALSE;
/* Update the table pointer */
- Value = InterlockedExchangePointer(&ThirdLevel[i], Mid);
+ Value = InterlockedExchangePointer((PVOID*)&ThirdLevel[i], Mid);
ASSERT(Value == NULL);
}
else
@@ -596,7 +596,7 @@
if (!Low) return FALSE;
/* Update the table pointer */
- Value = InterlockedExchangePointer(&ThirdLevel[i][j], Low);
+ Value = InterlockedExchangePointer((PVOID*)&ThirdLevel[i][j], Low);
ASSERT(Value == NULL);
}
}
@@ -886,8 +886,8 @@
/* It's not locked, remove the lock bit to lock it */
NewValue = OldValue & ~EXHANDLE_TABLE_ENTRY_LOCK_BIT;
if (InterlockedCompareExchangePointer(&HandleTableEntry->Object,
- NewValue,
- OldValue) == (PVOID)OldValue)
+ (PVOID)NewValue,
+ (PVOID)OldValue) == (PVOID)OldValue)
{
/* We locked it, get out */
return TRUE;
@@ -1010,7 +1010,7 @@
}
/* Clear the handle */
- Object = InterlockedExchangePointer(&HandleTableEntry->Object, NULL);
+ Object = InterlockedExchangePointer((PVOID*)&HandleTableEntry->Object, NULL);
/* Sanity checks */
ASSERT(Object != NULL);
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ex/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ex/init.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ex/init.c [iso-8859-1] Thu Jul 31 18:01:51
2008
@@ -68,7 +68,7 @@
ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
ULONG ExpUnicodeCaseTableDataOffset;
NLSTABLEINFO ExpNlsTableInfo;
-ULONG ExpNlsTableSize;
+SIZE_T ExpNlsTableSize;
PVOID ExpNlsSectionPointer;
/* CMOS Timer Sanity */
@@ -196,7 +196,7 @@
NTSTATUS Status;
HANDLE NlsSection;
PVOID SectionBase = NULL;
- ULONG ViewSize = 0;
+ SIZE_T ViewSize = 0;
LARGE_INTEGER SectionOffset = {{0}};
PLIST_ENTRY ListHead, NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
@@ -369,7 +369,7 @@
OUT PCHAR *ProcessEnvironment)
{
NTSTATUS Status;
- ULONG Size;
+ SIZE_T Size;
PWSTR p;
UNICODE_STRING NullString = RTL_CONSTANT_STRING(L"");
UNICODE_STRING SmssName, Environment, SystemDriveString, DebugString;
@@ -829,7 +829,7 @@
PLDR_DATA_TABLE_ENTRY NtosEntry;
PRTL_MESSAGE_RESOURCE_ENTRY MsgEntry;
ANSI_STRING CsdString;
- ULONG Remaining = 0;
+ SIZE_T Remaining = 0;
PCHAR RcEnd = NULL;
CHAR VersionBuffer [65];
@@ -1258,7 +1258,8 @@
PCHAR StringBuffer, EndBuffer, BeginBuffer, MpString = "";
PINIT_BUFFER InitBuffer;
ANSI_STRING TempString;
- ULONG LastTzBias, Size, Length, YearHack = 0, Disposition, MessageCode = 0;
+ ULONG LastTzBias, Size, YearHack = 0, Disposition, MessageCode = 0;
+ SIZE_T Length;
PRTL_USER_PROCESS_INFORMATION ProcessInfo;
KEY_VALUE_PARTIAL_INFORMATION KeyPartialInfo;
UNICODE_STRING KeyName, DebugString;
@@ -1738,7 +1739,7 @@
KeyValuePartialInformation,
&KeyPartialInfo,
sizeof(KeyPartialInfo),
- &Length);
+ &Size);
if (!NT_SUCCESS(Status)) AlternateShell = FALSE;
}
@@ -1890,17 +1891,17 @@
ZwClose(ProcessInfo->ProcessHandle);
/* Free the initial process environment */
- Size = 0;
+ Length = 0;
ZwFreeVirtualMemory(NtCurrentProcess(),
(PVOID*)&Environment,
- &Size,
+ &Length,
MEM_RELEASE);
/* Free the initial process parameters */
- Size = 0;
+ Length = 0;
ZwFreeVirtualMemory(NtCurrentProcess(),
(PVOID*)&ProcessParameters,
- &Size,
+ &Length,
MEM_RELEASE);
/* Increase init phase */
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ex/pushlock.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ex/pushlock.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ex/pushlock.c [iso-8859-1] Thu Jul 31
18:01:51 2008
@@ -19,6 +19,12 @@
#undef PEX_PUSH_LOCK
/* PRIVATE FUNCTIONS *********************************************************/
+
+#ifdef _WIN64
+#define InterlockedAndPointer(ptr,val) InterlockedAnd64((PLONGLONG)ptr,(LONGLONG)val)
+#else
+#define InterlockedAndPointer(ptr,val) InterlockedAnd((PLONG)ptr,(LONG)val)
+#endif
/*++
* @name ExpInitializePushLocks
@@ -87,7 +93,7 @@
ASSERT(NewValue.Waiting);
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
@@ -97,7 +103,7 @@
}
/* Save the First Block */
- FirstWaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)OldValue.Ptr &
+ FirstWaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value &
~EX_PUSH_LOCK_PTR_BITS);
WaitBlock = FirstWaitBlock;
@@ -135,7 +141,7 @@
ASSERT(!NewValue.Waking);
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) break;
@@ -154,7 +160,7 @@
ASSERT(PushLock->Waiting);
/* Remove waking bit from pushlock */
- InterlockedAnd((PLONG)PushLock, ~EX_PUSH_LOCK_WAKING);
+ InterlockedAndPointer(&PushLock->Value, ~EX_PUSH_LOCK_WAKING);
/* Leave the loop */
break;
@@ -236,7 +242,7 @@
}
/* Get the wait block */
- WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)OldValue.Ptr &
+ WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value &
~EX_PUSH_LOCK_PTR_BITS);
/* Loop the blocks */
@@ -270,7 +276,7 @@
ASSERT(!NewValue.Waking);
/* Update the value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
@@ -477,7 +483,7 @@
ASSERT(NewValue.Locked);
/* Set the new value */
- if (InterlockedCompareExchangePointer(PushLock,
+ if (InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr) != OldValue.Ptr)
{
@@ -507,8 +513,8 @@
WaitBlock->ShareCount = 0;
/* Set the current Wait Block pointer */
- WaitBlock->Next = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)
- OldValue.Ptr &~ EX_PUSH_LOCK_PTR_BITS);
+ WaitBlock->Next = (PEX_PUSH_LOCK_WAIT_BLOCK)(
+ OldValue.Value &~ EX_PUSH_LOCK_PTR_BITS);
/* Point to ours */
NewValue.Value = (OldValue.Value & EX_PUSH_LOCK_MULTIPLE_SHARED) |
@@ -563,7 +569,7 @@
/* Write the new value */
TempValue = NewValue;
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value != OldValue.Value)
@@ -655,7 +661,7 @@
ASSERT(NewValue.Locked);
/* Set the new value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value != OldValue.Value)
@@ -680,8 +686,8 @@
if (OldValue.Waiting)
{
/* Set the current Wait Block pointer */
- WaitBlock->Next = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)
- OldValue.Ptr &~ EX_PUSH_LOCK_PTR_BITS);
+ WaitBlock->Next = (PEX_PUSH_LOCK_WAIT_BLOCK)(
+ OldValue.Value &~ EX_PUSH_LOCK_PTR_BITS);
/* Nobody is the last waiter yet */
WaitBlock->Last = NULL;
@@ -719,7 +725,7 @@
#endif
/* Write the new value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Ptr != OldValue.Ptr)
@@ -810,7 +816,7 @@
}
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
@@ -824,7 +830,7 @@
if (OldValue.MultipleShared)
{
/* Get the wait block */
- WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)OldValue.Ptr &
+ WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value &
~EX_PUSH_LOCK_PTR_BITS);
/* Loop until we find the last wait block */
@@ -877,7 +883,7 @@
ASSERT(NewValue.Waking && !NewValue.Locked &&
!NewValue.MultipleShared);
/* Write the new value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr =
InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
@@ -897,7 +903,7 @@
/* Write the new value */
WakeValue = NewValue;
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr =
InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value != OldValue.Value) continue;
@@ -950,7 +956,7 @@
}
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
@@ -963,7 +969,7 @@
if (OldValue.MultipleShared)
{
/* Get the wait block */
- WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)OldValue.Ptr &
+ WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value &
~EX_PUSH_LOCK_PTR_BITS);
/* Loop until we find the last wait block */
@@ -1013,7 +1019,7 @@
ASSERT(NewValue.Waking && !NewValue.Locked &&
!NewValue.MultipleShared);
/* Write the new value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
@@ -1033,7 +1039,7 @@
/* Write the new value */
WakeValue = NewValue;
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value != OldValue.Value) continue;
@@ -1087,7 +1093,7 @@
/* Write the New Value. Save our original value for waking */
WakeValue = NewValue;
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
@@ -1108,7 +1114,7 @@
ASSERT(NewValue.Waking && !NewValue.Waiting);
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
@@ -1152,7 +1158,7 @@
NewValue.Waking = TRUE;
/* Write the New Value */
- if (InterlockedCompareExchangePointer(PushLock,
+ if (InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr) == OldValue.Ptr)
{
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/kdbg/kdb.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/kdbg/kdb.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/kdbg/kdb.c [iso-8859-1] Thu Jul 31
18:01:51 2008
@@ -201,6 +201,7 @@
RtlZeroMemory(KdbTrapFrame, sizeof(KDB_KTRAP_FRAME));
StackPtr = (ULONG_PTR *) KernelStack;
+#if _M_X86_
KdbTrapFrame->Tf.Ebp = StackPtr[3];
KdbTrapFrame->Tf.Edi = StackPtr[4];
KdbTrapFrame->Tf.Esi = StackPtr[5];
@@ -212,6 +213,7 @@
KdbTrapFrame->Tf.SegDs = KGDT_R0_DATA;
KdbTrapFrame->Tf.SegEs = KGDT_R0_DATA;
KdbTrapFrame->Tf.SegGs = KGDT_R0_DATA;
+#endif
/* FIXME: what about the other registers??? */
}
@@ -405,7 +407,7 @@
}
/* Get the interrupt descriptor */
- if (!NT_SUCCESS(KdbpSafeReadMemory(IntDesc, (PVOID)(Idtr.Base + (IntVect * 8)), sizeof
(IntDesc))))
+ if (!NT_SUCCESS(KdbpSafeReadMemory(IntDesc, (PVOID)(ULONG_PTR)(Idtr.Base + (IntVect *
8)), sizeof (IntDesc))))
{
/*KdbpPrint("Couldn't access memory at 0x%p\n", (ULONG_PTR)Idtr.Base
+ (IntVect * 8));*/
return FALSE;
@@ -1073,7 +1075,7 @@
/* Get a pointer to the thread */
if (!NT_SUCCESS(PsLookupThreadByThreadId(ThreadId, &Thread)))
{
- KdbpPrint("Invalid thread id: 0x%08x\n", (ULONG)ThreadId);
+ KdbpPrint("Invalid thread id: 0x%08x\n", (ULONG_PTR)ThreadId);
return FALSE;
}
Process = Thread->ThreadsProcess;
@@ -1152,14 +1154,14 @@
/* Get a pointer to the process */
if (!NT_SUCCESS(PsLookupProcessByProcessId(ProcessId, &Process)))
{
- KdbpPrint("Invalid process id: 0x%08x\n", (ULONG)ProcessId);
+ KdbpPrint("Invalid process id: 0x%08x\n", (ULONG_PTR)ProcessId);
return FALSE;
}
Entry = Process->ThreadListHead.Flink;
if (Entry == &KdbCurrentProcess->ThreadListHead)
{
- KdbpPrint("No threads in process 0x%08x, cannot attach to process!\n",
(ULONG)ProcessId);
+ KdbpPrint("No threads in process 0x%p, cannot attach to process!\n",
ProcessId);
return FALSE;
}
@@ -1200,7 +1202,7 @@
SavedStackLimit = Thread->Tcb.StackLimit;
SavedKernelStack = Thread->Tcb.KernelStack;
Thread->Tcb.InitialStack = Thread->Tcb.StackBase = (char*)KdbStack +
KDB_STACK_SIZE;
- Thread->Tcb.StackLimit = (ULONG)KdbStack;
+ Thread->Tcb.StackLimit = (ULONG_PTR)KdbStack;
Thread->Tcb.KernelStack = (char*)KdbStack + KDB_STACK_SIZE;
/*KdbpPrint("Switching to KDB stack 0x%08x-0x%08x\n",
Thread->Tcb.StackLimit, Thread->Tcb.StackBase);*/
@@ -1613,7 +1615,7 @@
TrapFrame->Dr6 &= ~0x0000e00f;
/* Skip the current instruction */
- Context->Eip++;
+// Context->Eip++;
}
return ContinueType;
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/se/audit.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/se/audit.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/se/audit.c [iso-8859-1] Thu Jul 31
18:01:51 2008
@@ -137,7 +137,7 @@
if (NT_SUCCESS(Status))
{
/* Set it */
- if (InterlockedCompareExchangePointer(&Process->
+ if (InterlockedCompareExchangePointer((PVOID*)&Process->
SeAuditProcessCreationInfo,
AuditName,
NULL))
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/se/lsa.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/se/lsa.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/se/lsa.c [iso-8859-1] Thu Jul 31 18:01:51
2008
@@ -49,7 +49,7 @@
NTAPI
LsaFreeReturnBuffer(PVOID Buffer)
{
- ULONG Size = 0;
+ SIZE_T Size = 0;
return ZwFreeVirtualMemory(NtCurrentProcess(),
&Buffer,
&Size,