mirror of
https://github.com/reactos/reactos.git
synced 2024-06-29 01:12:06 +00:00
- 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. svn path=/trunk/; revision=23260
This commit is contained in:
parent
5cfb6a6d48
commit
9b5a87cdac
|
@ -49,7 +49,7 @@
|
||||||
#endif
|
#endif
|
||||||
#define PSREFTRACE(x) \
|
#define PSREFTRACE(x) \
|
||||||
PSTRACE(PS_REF_DEBUG, \
|
PSTRACE(PS_REF_DEBUG, \
|
||||||
"Pointer Count [%p] @%lx: %lx\n", \
|
"Pointer Count [%p] @%d: %lx\n", \
|
||||||
x, \
|
x, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
OBJECT_TO_OBJECT_HEADER(x)->PointerCount);
|
OBJECT_TO_OBJECT_HEADER(x)->PointerCount);
|
||||||
|
|
|
@ -19,6 +19,14 @@
|
||||||
#define PspQuantumLengthFromMask(Mask) \
|
#define PspQuantumLengthFromMask(Mask) \
|
||||||
((Mask) & 48)
|
((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
|
VOID
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
PspRunCreateThreadNotifyRoutines(IN PETHREAD CurrentThread,
|
PspRunCreateThreadNotifyRoutines(IN PETHREAD CurrentThread,
|
||||||
|
|
|
@ -150,7 +150,7 @@ ObFastReferenceObject(IN PEX_FAST_REF FastRef)
|
||||||
{
|
{
|
||||||
/* Get the current count */
|
/* Get the current count */
|
||||||
Value = FastRef->Value;
|
Value = FastRef->Value;
|
||||||
if (!Value & MAX_FAST_REFS) break;
|
if (!(Value & MAX_FAST_REFS)) break;
|
||||||
|
|
||||||
/* Increase the reference count */
|
/* Increase the reference count */
|
||||||
NewValue = Value - 1;
|
NewValue = Value - 1;
|
||||||
|
|
|
@ -905,7 +905,7 @@ PspTerminateThreadByPointer(IN PETHREAD Thread,
|
||||||
ASSERT_IRQL(PASSIVE_LEVEL);
|
ASSERT_IRQL(PASSIVE_LEVEL);
|
||||||
|
|
||||||
/* Mark it as terminated */
|
/* Mark it as terminated */
|
||||||
InterlockedOr((PLONG)&Thread->CrossThreadFlags, CT_TERMINATED_BIT);
|
PspSetCrossThreadFlag(Thread, CT_TERMINATED_BIT);
|
||||||
|
|
||||||
/* Directly terminate the thread */
|
/* Directly terminate the thread */
|
||||||
PspExitThread(ExitStatus);
|
PspExitThread(ExitStatus);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "internal/ps_i.h"
|
#include "internal/ps_i.h"
|
||||||
|
|
||||||
/* Debugging Level */
|
/* Debugging Level */
|
||||||
ULONG PspTraceLevel = 0; //PS_KILL_DEBUG | PS_REF_DEBUG;
|
ULONG PspTraceLevel = PS_KILL_DEBUG | PS_REF_DEBUG;
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,7 @@ PspDeleteThreadSecurity(IN PETHREAD Thread)
|
||||||
{
|
{
|
||||||
/* Free it */
|
/* Free it */
|
||||||
ExFreePool(Thread->ImpersonationInfo);
|
ExFreePool(Thread->ImpersonationInfo);
|
||||||
InterlockedAnd((PLONG)&Thread->CrossThreadFlags,
|
PspClearCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
||||||
~CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
|
||||||
Thread->ImpersonationInfo = NULL;
|
Thread->ImpersonationInfo = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -537,8 +536,7 @@ PsRevertThreadToSelf(IN PETHREAD Thread)
|
||||||
if (Thread->ActiveImpersonationInfo)
|
if (Thread->ActiveImpersonationInfo)
|
||||||
{
|
{
|
||||||
/* Disable impersonation */
|
/* Disable impersonation */
|
||||||
InterlockedAnd((PLONG)&Thread->CrossThreadFlags,
|
PspClearCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
||||||
~CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
|
||||||
|
|
||||||
/* Get the token */
|
/* Get the token */
|
||||||
Token = Thread->ImpersonationInfo->Token;
|
Token = Thread->ImpersonationInfo->Token;
|
||||||
|
@ -584,8 +582,8 @@ PsImpersonateClient(IN PETHREAD Thread,
|
||||||
if (Thread->ActiveImpersonationInfo)
|
if (Thread->ActiveImpersonationInfo)
|
||||||
{
|
{
|
||||||
/* Disable impersonation */
|
/* Disable impersonation */
|
||||||
InterlockedAnd((PLONG)&Thread->CrossThreadFlags,
|
PspClearCrossThreadFlag(Thread,
|
||||||
~CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
||||||
|
|
||||||
/* Get the token */
|
/* Get the token */
|
||||||
OldToken = Thread->ImpersonationInfo->Token;
|
OldToken = Thread->ImpersonationInfo->Token;
|
||||||
|
@ -632,8 +630,7 @@ PsImpersonateClient(IN PETHREAD Thread,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Otherwise, enable impersonation */
|
/* Otherwise, enable impersonation */
|
||||||
InterlockedOr((PLONG)&Thread->CrossThreadFlags,
|
PspSetCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
||||||
CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now fill it out */
|
/* Now fill it out */
|
||||||
|
@ -880,14 +877,12 @@ PsRestoreImpersonation(IN PETHREAD Thread,
|
||||||
Impersonation->Token = ImpersonationState->Token;
|
Impersonation->Token = ImpersonationState->Token;
|
||||||
|
|
||||||
/* Enable impersonation */
|
/* Enable impersonation */
|
||||||
InterlockedOr((PLONG)&Thread->CrossThreadFlags,
|
PspSetCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
||||||
CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Disable impersonation */
|
/* Disable impersonation */
|
||||||
InterlockedAnd((PLONG)&Thread->CrossThreadFlags,
|
PspClearCrossThreadFlag(Thread, CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
||||||
~CT_ACTIVE_IMPERSONATION_INFO_BIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unlock the thread */
|
/* Unlock the thread */
|
||||||
|
|
|
@ -293,7 +293,7 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
|
||||||
{
|
{
|
||||||
/* System Thread */
|
/* System Thread */
|
||||||
Thread->StartAddress = StartRoutine;
|
Thread->StartAddress = StartRoutine;
|
||||||
InterlockedOr((PLONG)&Thread->CrossThreadFlags, CT_SYSTEM_THREAD_BIT);
|
PspSetCrossThreadFlag(Thread, CT_SYSTEM_THREAD_BIT);
|
||||||
|
|
||||||
/* Let the kernel intialize the Thread */
|
/* Let the kernel intialize the Thread */
|
||||||
Status = KeInitThread(&Thread->Tcb,
|
Status = KeInitThread(&Thread->Tcb,
|
||||||
|
@ -380,7 +380,7 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Access state failed, thread is dead */
|
/* 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 we were suspended, wake it up */
|
||||||
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
|
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
|
||||||
|
@ -422,7 +422,7 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
|
||||||
Status = _SEH_GetExceptionCode();
|
Status = _SEH_GetExceptionCode();
|
||||||
|
|
||||||
/* Thread insertion failed, thread is dead */
|
/* 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 we were suspended, wake it up */
|
||||||
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
|
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
|
||||||
|
@ -444,7 +444,7 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Thread insertion failed, thread is dead */
|
/* 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 we were suspended, wake it up */
|
||||||
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
|
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
|
||||||
|
@ -465,7 +465,7 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Thread insertion failed, thread is dead */
|
/* 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 we were suspended, wake it up */
|
||||||
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
|
if (CreateSuspended) KeResumeThread(&Thread->Tcb);
|
||||||
|
|
Loading…
Reference in a new issue