Author: ion
Date: Mon Jul 24 01:38:31 2006
New Revision: 23260
URL:
http://svn.reactos.org/svn/reactos?rev=23260&view=rev
Log:
- Fix trace macro to print line number in decimal, not hex.
- Implement PspSetCrossThreadFlag and PspClearCrossThreadFlag and use them. Thanks to
Thomas for the idea.
- Fix a bug in Fast Referencing, thanks to Thomas.
Modified:
trunk/reactos/ntoskrnl/include/internal/ps.h
trunk/reactos/ntoskrnl/include/internal/ps_x.h
trunk/reactos/ntoskrnl/ob/obref.c
trunk/reactos/ntoskrnl/ps/kill.c
trunk/reactos/ntoskrnl/ps/query.c
trunk/reactos/ntoskrnl/ps/security.c
trunk/reactos/ntoskrnl/ps/thread.c
Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ps.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ps.h Mon Jul 24 01:38:31 2006
@@ -49,7 +49,7 @@
#endif
#define PSREFTRACE(x) \
PSTRACE(PS_REF_DEBUG, \
- "Pointer Count [%p] @%lx: %lx\n", \
+ "Pointer Count [%p] @%d: %lx\n", \
x, \
__LINE__, \
OBJECT_TO_OBJECT_HEADER(x)->PointerCount);
Modified: trunk/reactos/ntoskrnl/include/internal/ps_x.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ps_x.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ps_x.h Mon Jul 24 01:38:31 2006
@@ -18,6 +18,14 @@
#define PspQuantumLengthFromMask(Mask) \
((Mask) & 48)
+
+//
+// Cross Thread Flag routines
+//
+#define PspSetCrossThreadFlag(Thread, Flag) \
+ InterlockedOr((PLONG)&Thread->CrossThreadFlags, Flag)
+#define PspClearCrossThreadFlag(Thread, Flag) \
+ InterlockedAnd((PLONG)&Thread->CrossThreadFlags, ~Flag)
VOID
FORCEINLINE
Modified: trunk/reactos/ntoskrnl/ob/obref.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obref.c?rev=23…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obref.c (original)
+++ trunk/reactos/ntoskrnl/ob/obref.c Mon Jul 24 01:38:31 2006
@@ -150,7 +150,7 @@
{
/* Get the current count */
Value = FastRef->Value;
- if (!Value & MAX_FAST_REFS) break;
+ if (!(Value & MAX_FAST_REFS)) break;
/* Increase the reference count */
NewValue = Value - 1;
Modified: trunk/reactos/ntoskrnl/ps/kill.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/kill.c?rev=232…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/kill.c (original)
+++ trunk/reactos/ntoskrnl/ps/kill.c Mon Jul 24 01:38:31 2006
@@ -905,7 +905,7 @@
ASSERT_IRQL(PASSIVE_LEVEL);
/* Mark it as terminated */
- InterlockedOr((PLONG)&Thread->CrossThreadFlags, CT_TERMINATED_BIT);
+ PspSetCrossThreadFlag(Thread, CT_TERMINATED_BIT);
/* Directly terminate the thread */
PspExitThread(ExitStatus);
Modified: trunk/reactos/ntoskrnl/ps/query.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/query.c?rev=23…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/query.c (original)
+++ trunk/reactos/ntoskrnl/ps/query.c Mon Jul 24 01:38:31 2006
@@ -17,7 +17,7 @@
#include "internal/ps_i.h"
/* Debugging Level */
-ULONG PspTraceLevel = 0; //PS_KILL_DEBUG | PS_REF_DEBUG;
+ULONG PspTraceLevel = PS_KILL_DEBUG | PS_REF_DEBUG;
/* PRIVATE FUNCTIONS *********************************************************/
Modified: trunk/reactos/ntoskrnl/ps/security.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/security.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/security.c (original)
+++ trunk/reactos/ntoskrnl/ps/security.c Mon Jul 24 01:38:31 2006
@@ -51,8 +51,7 @@
{
/* Free it */
ExFreePool(Thread->ImpersonationInfo);
- InterlockedAnd((PLONG)&Thread->CrossThreadFlags,
- ~CT_ACTIVE_IMPERSONATION_INFO_BIT);
+ PspClearCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
Thread->ImpersonationInfo = NULL;
}
}
@@ -537,8 +536,7 @@
if (Thread->ActiveImpersonationInfo)
{
/* Disable impersonation */
- InterlockedAnd((PLONG)&Thread->CrossThreadFlags,
- ~CT_ACTIVE_IMPERSONATION_INFO_BIT);
+ PspClearCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
/* Get the token */
Token = Thread->ImpersonationInfo->Token;
@@ -584,8 +582,8 @@
if (Thread->ActiveImpersonationInfo)
{
/* Disable impersonation */
- InterlockedAnd((PLONG)&Thread->CrossThreadFlags,
- ~CT_ACTIVE_IMPERSONATION_INFO_BIT);
+ PspClearCrossThreadFlag(Thread,
+ CT_ACTIVE_IMPERSONATION_INFO_BIT);
/* Get the token */
OldToken = Thread->ImpersonationInfo->Token;
@@ -632,8 +630,7 @@
else
{
/* Otherwise, enable impersonation */
- InterlockedOr((PLONG)&Thread->CrossThreadFlags,
- CT_ACTIVE_IMPERSONATION_INFO_BIT);
+ PspSetCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
}
/* Now fill it out */
@@ -880,14 +877,12 @@
Impersonation->Token = ImpersonationState->Token;
/* Enable impersonation */
- InterlockedOr((PLONG)&Thread->CrossThreadFlags,
- CT_ACTIVE_IMPERSONATION_INFO_BIT);
+ PspSetCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
}
else
{
/* Disable impersonation */
- InterlockedAnd((PLONG)&Thread->CrossThreadFlags,
- ~CT_ACTIVE_IMPERSONATION_INFO_BIT);
+ PspClearCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
}
/* Unlock the thread */
Modified: trunk/reactos/ntoskrnl/ps/thread.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/thread.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/thread.c (original)
+++ trunk/reactos/ntoskrnl/ps/thread.c Mon Jul 24 01:38:31 2006
@@ -293,7 +293,7 @@
{
/* System Thread */
Thread->StartAddress = StartRoutine;
- InterlockedOr((PLONG)&Thread->CrossThreadFlags, CT_SYSTEM_THREAD_BIT);
+ PspSetCrossThreadFlag(Thread, CT_SYSTEM_THREAD_BIT);
/* Let the kernel intialize the Thread */
Status = KeInitThread(&Thread->Tcb,
@@ -380,7 +380,7 @@
if (!NT_SUCCESS(Status))
{
/* Access state failed, thread is dead */
- InterlockedOr((PLONG)&Thread->CrossThreadFlags, CT_DEAD_THREAD_BIT);
+ PspSetCrossThreadFlag(Thread, CT_DEAD_THREAD_BIT);
/* If we were suspended, wake it up */
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
@@ -422,7 +422,7 @@
Status = _SEH_GetExceptionCode();
/* Thread insertion failed, thread is dead */
- InterlockedOr((PLONG)&Thread->CrossThreadFlags, CT_DEAD_THREAD_BIT);
+ PspSetCrossThreadFlag(Thread, CT_DEAD_THREAD_BIT);
/* If we were suspended, wake it up */
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
@@ -444,7 +444,7 @@
else
{
/* Thread insertion failed, thread is dead */
- InterlockedOr((PLONG)&Thread->CrossThreadFlags, CT_DEAD_THREAD_BIT);
+ PspSetCrossThreadFlag(Thread, CT_DEAD_THREAD_BIT);
/* If we were suspended, wake it up */
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
@@ -465,7 +465,7 @@
if (!NT_SUCCESS(Status))
{
/* Thread insertion failed, thread is dead */
- InterlockedOr((PLONG)&Thread->CrossThreadFlags, CT_DEAD_THREAD_BIT);
+ PspSetCrossThreadFlag(Thread, CT_DEAD_THREAD_BIT);
/* If we were suspended, wake it up */
if (CreateSuspended) KeResumeThread(&Thread->Tcb);