From bb766d54042be1338b97db0dc7f5fd7c7a1ffc6e Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sat, 5 Feb 2005 10:31:37 +0000 Subject: [PATCH] only attach to the process to be queried when necessary svn path=/trunk/; revision=13421 --- reactos/ntoskrnl/ke/spinlock.c | 4 +--- reactos/ntoskrnl/ps/process.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/reactos/ntoskrnl/ke/spinlock.c b/reactos/ntoskrnl/ke/spinlock.c index 47fa9dd4258..15c3b13737c 100644 --- a/reactos/ntoskrnl/ke/spinlock.c +++ b/reactos/ntoskrnl/ke/spinlock.c @@ -195,9 +195,7 @@ KiAcquireSpinLock(PKSPIN_LOCK SpinLock) : : "r" (SpinLock)); #else - while (0 != *(volatile PKSPIN_LOCK)SpinLock) - { - } + while (0 != *(volatile KSPIN_LOCK*)SpinLock); #endif #else DbgPrint("Spinning on spinlock %x current value %x\n", SpinLock, i); diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index a0edaaecfd6..00c5dec9c6c 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -1613,11 +1613,15 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, { PRTL_USER_PROCESS_PARAMETERS ProcParams = NULL; UNICODE_STRING LocalDest; + BOOLEAN Attached; ULONG ImagePathLen = 0; PUNICODE_STRING DstPath = (PUNICODE_STRING)ProcessInformation; /* we need to attach to the process to make sure we're in the right context! */ - KeAttachProcess(&Process->Pcb); + Attached = Process != PsGetCurrentProcess(); + + if(Attached) + KeAttachProcess(&Process->Pcb); _SEH_TRY { @@ -1677,7 +1681,8 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, _SEH_END; /* detach from the process */ - KeDetachProcess(); + if(Attached) + KeDetachProcess(); /* only copy the string back to the caller if we were able to copy it into the temporary buffer! */ @@ -1715,7 +1720,8 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, } /* don't forget to detach from the process!!! */ - KeDetachProcess(); + if(Attached) + KeDetachProcess(); } else {