- PsLookup* functions fixed to increment the reference count of the object they are about to return. The GDB KD stub is directly affected by this patch, but it hasn't been fixed yet

- PsGetCurrentProcess and PsGetCurrentThread are now macros calling IoGetCurrentProcess and KeGetCurrentThread, for binary compatibility with Windows

svn path=/trunk/; revision=4521
This commit is contained in:
KJK::Hyperion 2003-04-10 23:14:47 +00:00
parent 71c3c7c1cc
commit 5c6df46d27
7 changed files with 20 additions and 27 deletions

View file

@ -185,7 +185,7 @@ ExFreePool (
* ); * );
*/ */
#define ExGetCurrentResourceThread() \ #define ExGetCurrentResourceThread() \
((ERESOURCE_THREAD)PsGetCurrentThread()) ((ERESOURCE_THREAD)KeGetCurrentThread())
ULONG ULONG
STDCALL STDCALL

View file

@ -1,4 +1,4 @@
/* $Id: extypes.h,v 1.13 2003/03/19 23:14:11 gdalsnes Exp $ */ /* $Id: extypes.h,v 1.14 2003/04/10 23:14:46 hyperion Exp $ */
#ifndef __INCLUDE_DDK_EXTYPES_H #ifndef __INCLUDE_DDK_EXTYPES_H
#define __INCLUDE_DDK_EXTYPES_H #define __INCLUDE_DDK_EXTYPES_H
@ -18,7 +18,7 @@ extern POBJECT_TYPE IMPORTED ExIoCompletionType;
typedef ULONG INTERLOCKED_RESULT; typedef ULONG INTERLOCKED_RESULT;
typedef ULONG WORK_QUEUE_TYPE; typedef ULONG WORK_QUEUE_TYPE;
typedef ULONG ERESOURCE_THREAD, *PERESOURCE_THREAD; typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
typedef struct _OWNER_ENTRY typedef struct _OWNER_ENTRY
{ {

View file

@ -1,4 +1,4 @@
/* $Id: psfuncs.h,v 1.22 2002/09/08 10:47:45 chorns Exp $ /* $Id: psfuncs.h,v 1.23 2003/04/10 23:14:46 hyperion Exp $
*/ */
#ifndef _INCLUDE_DDK_PSFUNCS_H #ifndef _INCLUDE_DDK_PSFUNCS_H
#define _INCLUDE_DDK_PSFUNCS_H #define _INCLUDE_DDK_PSFUNCS_H
@ -48,8 +48,9 @@ VOID STDCALL PsEstablishWin32Callouts(PVOID Param1,
ULONG W32ThreadSize, ULONG W32ThreadSize,
ULONG W32ProcessSize); ULONG W32ProcessSize);
struct _ETHREAD* STDCALL PsGetCurrentThread(VOID); #define PsGetCurrentProcess() IoGetCurrentProcess()
struct _EPROCESS* STDCALL PsGetCurrentProcess(VOID); #define PsGetCurrentThread() ((struct _ETHREAD*) (KeGetCurrentThread()))
PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(struct _ETHREAD* Thread, PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(struct _ETHREAD* Thread,
PULONG Unknown1, PULONG Unknown1,
PULONG Unknown2, PULONG Unknown2,

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.149 2003/04/06 10:45:16 chorns Exp $ ; $Id: ntoskrnl.def,v 1.150 2003/04/10 23:14:46 hyperion Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -636,10 +636,8 @@ PsCreateWin32Process@4
PsGetWin32Thread@0 PsGetWin32Thread@0
PsGetWin32Process@0 PsGetWin32Process@0
PsEstablishWin32Callouts@24 PsEstablishWin32Callouts@24
PsGetCurrentProcess@0
PsGetCurrentProcessId@0 PsGetCurrentProcessId@0
PsGetCurrentThreadId@0 PsGetCurrentThreadId@0
PsGetCurrentThread@0
PsGetProcessExitTime@0 PsGetProcessExitTime@0
PsGetVersion@16 PsGetVersion@16
PsImpersonateClient@20 PsImpersonateClient@20

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.135 2003/04/06 10:45:16 chorns Exp $ ; $Id: ntoskrnl.edf,v 1.136 2003/04/10 23:14:47 hyperion Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -635,10 +635,8 @@ PsCreateWin32Process=PsCreateWin32Process@4
PsGetWin32Thread=PsGetWin32Thread@0 PsGetWin32Thread=PsGetWin32Thread@0
PsGetWin32Process=PsGetWin32Process@0 PsGetWin32Process=PsGetWin32Process@0
PsEstablishWin32Callouts=PsEstablishWin32Callouts@24 PsEstablishWin32Callouts=PsEstablishWin32Callouts@24
PsGetCurrentProcess=PsGetCurrentProcess@0
PsGetCurrentProcessId=PsGetCurrentProcessId@0 PsGetCurrentProcessId=PsGetCurrentProcessId@0
PsGetCurrentThreadId=PsGetCurrentThreadId@0 PsGetCurrentThreadId=PsGetCurrentThreadId@0
PsGetCurrentThread=PsGetCurrentThread@0
PsGetProcessExitTime=PsGetProcessExitTime@0 PsGetProcessExitTime=PsGetProcessExitTime@0
PsGetVersion=PsGetVersion@16 PsGetVersion=PsGetVersion@16
PsImpersonateClient=PsImpersonateClient@20 PsImpersonateClient=PsImpersonateClient@20

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.95 2003/01/19 01:46:32 hbirr Exp $ /* $Id: process.c,v 1.96 2003/04/10 23:14:47 hyperion Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -368,7 +368,7 @@ PsGetCurrentProcessId(VOID)
* FUNCTION: Returns a pointer to the current process * FUNCTION: Returns a pointer to the current process
*/ */
PEPROCESS STDCALL PEPROCESS STDCALL
PsGetCurrentProcess(VOID) IoGetCurrentProcess(VOID)
{ {
if (PsGetCurrentThread() == NULL || if (PsGetCurrentThread() == NULL ||
PsGetCurrentThread()->ThreadsProcess == NULL) PsGetCurrentThread()->ThreadsProcess == NULL)
@ -381,12 +381,6 @@ PsGetCurrentProcess(VOID)
} }
} }
PEPROCESS STDCALL
IoGetCurrentProcess(VOID)
{
return(PsGetCurrentProcess());
}
NTSTATUS STDCALL NTSTATUS STDCALL
PsCreateSystemProcess(PHANDLE ProcessHandle, PsCreateSystemProcess(PHANDLE ProcessHandle,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
@ -1220,6 +1214,7 @@ PsLookupProcessByProcessId(IN PVOID ProcessId,
if (current->UniqueProcessId == (ULONG)ProcessId) if (current->UniqueProcessId == (ULONG)ProcessId)
{ {
*Process = current; *Process = current;
ObReferenceObject(current);
KeReleaseSpinLock(&PsProcessListLock, oldIrql); KeReleaseSpinLock(&PsProcessListLock, oldIrql);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.107 2003/03/19 23:08:46 gdalsnes Exp $ /* $Id: thread.c,v 1.108 2003/04/10 23:14:47 hyperion Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -66,12 +66,6 @@ PKTHREAD STDCALL KeGetCurrentThread(VOID)
return(KeGetCurrentKPCR()->CurrentThread); return(KeGetCurrentKPCR()->CurrentThread);
} }
PETHREAD STDCALL PsGetCurrentThread(VOID)
{
PKTHREAD CurrentThread = KeGetCurrentKPCR()->CurrentThread;
return(CONTAINING_RECORD(CurrentThread, ETHREAD, Tcb));
}
HANDLE STDCALL PsGetCurrentThreadId(VOID) HANDLE STDCALL PsGetCurrentThreadId(VOID)
{ {
return(PsGetCurrentThread()->Cid.UniqueThread); return(PsGetCurrentThread()->Cid.UniqueThread);
@ -603,8 +597,14 @@ PsLookupProcessThreadByCid(IN PCLIENT_ID Cid,
current->Cid.UniqueProcess == Cid->UniqueProcess) current->Cid.UniqueProcess == Cid->UniqueProcess)
{ {
if (Process != NULL) if (Process != NULL)
{
*Process = current->ThreadsProcess; *Process = current->ThreadsProcess;
ObReferenceObject(current->ThreadsProcess);
}
*Thread = current; *Thread = current;
ObReferenceObject(current);
KeReleaseSpinLock(&PiThreadListLock, oldIrql); KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -637,6 +637,7 @@ PsLookupThreadByThreadId(IN PVOID ThreadId,
if (current->Cid.UniqueThread == (HANDLE)ThreadId) if (current->Cid.UniqueThread == (HANDLE)ThreadId)
{ {
*Thread = current; *Thread = current;
ObReferenceObject(current);
KeReleaseSpinLock(&PiThreadListLock, oldIrql); KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }