Implemented PsLookupXxx() functions.

svn path=/trunk/; revision=2477
This commit is contained in:
Eric Kohl 2002-01-03 14:03:05 +00:00
parent 3221f88ce3
commit 1806f623e7
6 changed files with 142 additions and 21 deletions

View file

@ -1,4 +1,4 @@
/* $Id: psfuncs.h,v 1.16 2001/11/29 16:39:45 ekohl Exp $ /* $Id: psfuncs.h,v 1.17 2002/01/03 14:01:16 ekohl Exp $
*/ */
#ifndef _INCLUDE_DDK_PSFUNCS_H #ifndef _INCLUDE_DDK_PSFUNCS_H
#define _INCLUDE_DDK_PSFUNCS_H #define _INCLUDE_DDK_PSFUNCS_H
@ -38,6 +38,15 @@ NTSTATUS STDCALL PsCreateSystemProcess(PHANDLE ProcessHandle,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes); POBJECT_ATTRIBUTES ObjectAttributes);
NTSTATUS STDCALL PsCreateWin32Process(PEPROCESS Process);
VOID STDCALL PsEstablishWin32Callouts(PVOID Param1,
PVOID Param2,
PVOID Param3,
PVOID Param4,
PVOID Param5,
ULONG W32ProcessSize);
struct _ETHREAD* STDCALL PsGetCurrentThread(VOID); struct _ETHREAD* STDCALL PsGetCurrentThread(VOID);
struct _EPROCESS* STDCALL PsGetCurrentProcess(VOID); struct _EPROCESS* STDCALL PsGetCurrentProcess(VOID);
PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(struct _ETHREAD* Thread, PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(struct _ETHREAD* Thread,
@ -66,6 +75,18 @@ VOID STDCALL PsDispatchThread(ULONG NewThreadStatus);
LARGE_INTEGER STDCALL PsGetProcessExitTime(VOID); LARGE_INTEGER STDCALL PsGetProcessExitTime(VOID);
BOOLEAN STDCALL PsIsThreadTerminating(struct _ETHREAD* Thread); BOOLEAN STDCALL PsIsThreadTerminating(struct _ETHREAD* Thread);
NTSTATUS STDCALL PsLookupProcessByProcessId(IN PVOID ProcessId,
OUT PEPROCESS *Process);
NTSTATUS STDCALL PsLookupProcessThreadByCid(IN PCLIENT_ID Cid,
OUT PEPROCESS *Process OPTIONAL,
OUT struct _ETHREAD **Thread);
// OUT PETHREAD *Thread);
NTSTATUS STDCALL PsLookupThreadByThreadId(IN PVOID ThreadId,
OUT struct _ETHREAD **Thread);
// OUT PETHREAD *Thread);
#endif #endif
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.120 2001/11/29 16:41:22 ekohl Exp $ ; $Id: ntoskrnl.def,v 1.121 2002/01/03 14:02:04 ekohl Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -601,9 +601,9 @@ PsGetVersion@16
PsImpersonateClient@20 PsImpersonateClient@20
PsInitialSystemProcess DATA PsInitialSystemProcess DATA
PsIsThreadTerminating@4 PsIsThreadTerminating@4
;PsLookupProcessByProcessId@8 PsLookupProcessByProcessId@8
;PsLookupProcessThreadByCid@12 PsLookupProcessThreadByCid@12
;PsLookupThreadByThreadId@8 PsLookupThreadByThreadId@8
PsProcessType DATA PsProcessType DATA
PsReferenceImpersonationToken@16 PsReferenceImpersonationToken@16
PsReferencePrimaryToken@4 PsReferencePrimaryToken@4

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.106 2001/11/29 16:41:22 ekohl Exp $ ; $Id: ntoskrnl.edf,v 1.107 2002/01/03 14:02:04 ekohl Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -590,9 +590,9 @@ PsAssignImpersonationToken=PsAssignImpersonationToken@8
;PsChargePoolQuota=PsChargePoolQuota@12 ;PsChargePoolQuota=PsChargePoolQuota@12
PsCreateSystemProcess=PsCreateSystemProcess@12 PsCreateSystemProcess=PsCreateSystemProcess@12
PsCreateSystemThread=PsCreateSystemThread@28 PsCreateSystemThread=PsCreateSystemThread@28
;PsCreateWin32Process ;PsCreateWin32Process=PsCreateWin32Process@4
PsDispatchThread=PsDispatchThread@4 PsDispatchThread=PsDispatchThread@4
;PsEstablishWin32Callouts ;PsEstablishWin32Callouts=PsEstablishWin32Callouts@24
PsGetCurrentProcessId=PsGetCurrentProcessId@0 PsGetCurrentProcessId=PsGetCurrentProcessId@0
PsGetCurrentThreadId=PsGetCurrentThreadId@0 PsGetCurrentThreadId=PsGetCurrentThreadId@0
PsGetCurrentThread=PsGetCurrentThread@0 PsGetCurrentThread=PsGetCurrentThread@0
@ -601,9 +601,9 @@ PsGetVersion=PsGetVersion@16
PsImpersonateClient=PsImpersonateClient@20 PsImpersonateClient=PsImpersonateClient@20
PsInitialSystemProcess DATA PsInitialSystemProcess DATA
PsIsThreadTerminating=PsIsThreadTerminating@4 PsIsThreadTerminating=PsIsThreadTerminating@4
;PsLookupProcessByProcessId PsLookupProcessByProcessId=PsLookupProcessByProcessId@8
;PsLookupProcessThreadByCid PsLookupProcessThreadByCid=PsLookupProcessThreadByCid@12
;PsLookupThreadByThreadId PsLookupThreadByThreadId=PsLookupThreadByThreadId@8
PsProcessType DATA PsProcessType DATA
PsReferenceImpersonationToken=PsReferenceImpersonationToken@16 PsReferenceImpersonationToken=PsReferenceImpersonationToken@16
PsReferencePrimaryToken=PsReferencePrimaryToken@4 PsReferencePrimaryToken=PsReferencePrimaryToken@4

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.73 2002/01/03 12:48:02 chorns Exp $ /* $Id: process.c,v 1.74 2002/01/03 14:03:05 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -66,11 +66,11 @@ PsGetNextProcess(PEPROCESS OldProcess)
{ {
NextProcess = CONTAINING_RECORD(PsProcessListHead.Flink, NextProcess = CONTAINING_RECORD(PsProcessListHead.Flink,
EPROCESS, EPROCESS,
ProcessListEntry); ProcessListEntry);
} }
else else
{ {
NextProcess = CONTAINING_RECORD(OldProcess->ProcessListEntry.Flink, NextProcess = CONTAINING_RECORD(OldProcess->ProcessListEntry.Flink,
EPROCESS, EPROCESS,
ProcessListEntry); ProcessListEntry);
} }
@ -1152,4 +1152,35 @@ PsIsThreadTerminating(IN PETHREAD Thread)
return(Thread->DeadThread); return(Thread->DeadThread);
} }
NTSTATUS STDCALL
PsLookupProcessByProcessId(IN PVOID ProcessId,
OUT PEPROCESS *Process)
{
KIRQL oldIrql;
PLIST_ENTRY current_entry;
PEPROCESS current;
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
current_entry = PsProcessListHead.Flink;
while (current_entry != &PsProcessListHead)
{
current = CONTAINING_RECORD(current_entry,
EPROCESS,
ProcessListEntry);
if (current->UniqueProcessId == (ULONG)ProcessId)
{
*Process = current;
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
return(STATUS_SUCCESS);
}
current_entry = current_entry->Flink;
}
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
return(STATUS_INVALID_PARAMETER);
}
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.81 2001/12/31 19:06:48 dwelch Exp $ /* $Id: thread.c,v 1.82 2002/01/03 14:03:05 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -534,7 +534,7 @@ NtContinue(IN PCONTEXT Context,
} }
NTSTATUS STDCALL NTSTATUS STDCALL
NtYieldExecution(VOID) NtYieldExecution(VOID)
{ {
PsDispatchThread(THREAD_STATE_RUNNABLE); PsDispatchThread(THREAD_STATE_RUNNABLE);
@ -542,4 +542,71 @@ NtYieldExecution(VOID)
} }
NTSTATUS STDCALL
PsLookupProcessThreadByCid(IN PCLIENT_ID Cid,
OUT PEPROCESS *Process OPTIONAL,
OUT PETHREAD *Thread)
{
KIRQL oldIrql;
PLIST_ENTRY current_entry;
PETHREAD current;
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
current_entry = PiThreadListHead.Flink;
while (current_entry != &PiThreadListHead)
{
current = CONTAINING_RECORD(current_entry,
ETHREAD,
Tcb.ThreadListEntry);
if (current->Cid.UniqueThread == Cid->UniqueThread &&
current->Cid.UniqueProcess == Cid->UniqueProcess)
{
if (Process != NULL)
*Process = current->ThreadsProcess;
*Thread = current;
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(STATUS_SUCCESS);
}
current_entry = current_entry->Flink;
}
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(STATUS_INVALID_PARAMETER);
}
NTSTATUS STDCALL
PsLookupThreadByThreadId(IN PVOID ThreadId,
OUT PETHREAD *Thread)
{
KIRQL oldIrql;
PLIST_ENTRY current_entry;
PETHREAD current;
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
current_entry = PiThreadListHead.Flink;
while (current_entry != &PiThreadListHead)
{
current = CONTAINING_RECORD(current_entry,
ETHREAD,
Tcb.ThreadListEntry);
if (current->Cid.UniqueThread == (HANDLE)ThreadId)
{
*Thread = current;
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(STATUS_SUCCESS);
}
current_entry = current_entry->Flink;
}
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(STATUS_INVALID_PARAMETER);
}
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: tinfo.c,v 1.16 2001/09/07 21:35:45 ea Exp $ /* $Id: tinfo.c,v 1.17 2002/01/03 14:03:05 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -30,7 +30,7 @@ NtSetInformationThread(HANDLE ThreadHandle,
Status = ObReferenceObjectByHandle(ThreadHandle, Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_SET_INFORMATION, THREAD_SET_INFORMATION,
PsThreadType, PsThreadType,
UserMode, ExGetPreviousMode(),
(PVOID*)&Thread, (PVOID*)&Thread,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -112,8 +112,10 @@ NtSetInformationThread(HANDLE ThreadHandle,
break; break;
case ThreadZeroTlsCell: case ThreadZeroTlsCell:
Status = STATUS_NOT_IMPLEMENTED; {
break; Status = STATUS_NOT_IMPLEMENTED;
break;
}
case ThreadPerformanceCount: case ThreadPerformanceCount:
/* Can only be queried */ /* Can only be queried */
@ -167,7 +169,7 @@ NtQueryInformationThread (IN HANDLE ThreadHandle,
Status = ObReferenceObjectByHandle(ThreadHandle, Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_QUERY_INFORMATION, THREAD_QUERY_INFORMATION,
PsThreadType, PsThreadType,
UserMode, ExGetPreviousMode(),
(PVOID*)&Thread, (PVOID*)&Thread,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))