mirror of
https://github.com/reactos/reactos.git
synced 2024-10-01 23:14:53 +00:00
1. get rid of the global thread list and group threads in processes instead
2. get rid of all reactos-specific fields in the E/KTHREAD structure and make them match the 2k layout 3. identify threads (and later processes) using a client id table (which should propably be replaced by a global handle table instead) 4. disabled thread event pair functions by default (NT4 only) as they require a field in the ETHREAD structure that is not present in later versions svn path=/trunk/; revision=11105
This commit is contained in:
parent
c0e4836b17
commit
2d01207958
|
@ -1,4 +1,4 @@
|
||||||
# $Id: Makefile,v 1.143 2004/09/23 11:27:58 ekohl Exp $
|
# $Id: Makefile,v 1.144 2004/09/28 15:02:28 weiden Exp $
|
||||||
#
|
#
|
||||||
# ReactOS Operating System
|
# ReactOS Operating System
|
||||||
#
|
#
|
||||||
|
@ -61,6 +61,9 @@ CFLAGS += -D_DISABLE_TIDENTS
|
||||||
# no native setjmp/longjmp in the kernel
|
# no native setjmp/longjmp in the kernel
|
||||||
CFLAGS += -D_SEH_NO_NATIVE_NLG
|
CFLAGS += -D_SEH_NO_NATIVE_NLG
|
||||||
|
|
||||||
|
# enable thread event pair features (NT4 only!)
|
||||||
|
# CFLAGS += -D_ENABLE_THRDEVTPAIR
|
||||||
|
|
||||||
CFLAGS += $(STD_CFLAGS)
|
CFLAGS += $(STD_CFLAGS)
|
||||||
ASFLAGS += $(STD_ASFLAGS)
|
ASFLAGS += $(STD_ASFLAGS)
|
||||||
RCFLAGS += $(STD_RCFLAGS)
|
RCFLAGS += $(STD_RCFLAGS)
|
||||||
|
@ -249,6 +252,7 @@ OBJECTS_OB = \
|
||||||
|
|
||||||
# Process Manager (Ps)
|
# Process Manager (Ps)
|
||||||
OBJECTS_PS = \
|
OBJECTS_PS = \
|
||||||
|
ps/cid.o \
|
||||||
ps/create.o \
|
ps/create.o \
|
||||||
ps/debug.o \
|
ps/debug.o \
|
||||||
ps/idle.o \
|
ps/idle.o \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: sysinfo.c,v 1.45 2004/08/18 20:41:03 navaraf Exp $
|
/* $Id: sysinfo.c,v 1.46 2004/09/28 15:02:28 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -622,7 +622,7 @@ QSI_DEF(SystemProcessInformation)
|
||||||
while (current_entry != &pr->ThreadListHead)
|
while (current_entry != &pr->ThreadListHead)
|
||||||
{
|
{
|
||||||
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
||||||
Tcb.ProcessThreadListEntry);
|
ThreadListEntry);
|
||||||
|
|
||||||
SpiCur->Threads[i].KernelTime.QuadPart = current->Tcb.KernelTime * 100000LL;
|
SpiCur->Threads[i].KernelTime.QuadPart = current->Tcb.KernelTime * 100000LL;
|
||||||
SpiCur->Threads[i].UserTime.QuadPart = current->Tcb.UserTime * 100000LL;
|
SpiCur->Threads[i].UserTime.QuadPart = current->Tcb.UserTime * 100000LL;
|
||||||
|
|
|
@ -99,11 +99,13 @@ ExpInitializeCallbacks(VOID);
|
||||||
|
|
||||||
/* OTHER FUNCTIONS **********************************************************/
|
/* OTHER FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
|
#ifdef _ENABLE_THRDEVTPAIR
|
||||||
VOID
|
VOID
|
||||||
ExpSwapThreadEventPair(
|
ExpSwapThreadEventPair(
|
||||||
IN struct _ETHREAD* Thread,
|
IN struct _ETHREAD* Thread,
|
||||||
IN struct _KEVENT_PAIR* EventPair
|
IN struct _KEVENT_PAIR* EventPair
|
||||||
);
|
);
|
||||||
|
#endif /* _ENABLE_THRDEVTPAIR */
|
||||||
|
|
||||||
LONGLONG
|
LONGLONG
|
||||||
FASTCALL
|
FASTCALL
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: ps.h,v 1.68 2004/09/22 22:31:46 weiden Exp $
|
/* $Id: ps.h,v 1.69 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* FILE: ntoskrnl/ke/kthread.c
|
* FILE: ntoskrnl/ke/kthread.c
|
||||||
* PURPOSE: Process manager definitions
|
* PURPOSE: Process manager definitions
|
||||||
|
@ -96,13 +96,13 @@ typedef struct _KTHREAD
|
||||||
UCHAR Alerted[2]; /* 2E */
|
UCHAR Alerted[2]; /* 2E */
|
||||||
UCHAR Iopl; /* 30 */
|
UCHAR Iopl; /* 30 */
|
||||||
UCHAR NpxState; /* 31 */
|
UCHAR NpxState; /* 31 */
|
||||||
UCHAR Saturation; /* 32 */
|
CHAR Saturation; /* 32 */
|
||||||
CHAR Priority; /* 33 */
|
CHAR Priority; /* 33 */
|
||||||
KAPC_STATE ApcState; /* 34 */
|
KAPC_STATE ApcState; /* 34 */
|
||||||
ULONG ContextSwitches; /* 4C */
|
ULONG ContextSwitches; /* 4C */
|
||||||
ULONG WaitStatus; /* 50 */
|
LONG WaitStatus; /* 50 */
|
||||||
KIRQL WaitIrql; /* 54 */
|
KIRQL WaitIrql; /* 54 */
|
||||||
UCHAR WaitMode; /* 55 */
|
CHAR WaitMode; /* 55 */
|
||||||
UCHAR WaitNext; /* 56 */
|
UCHAR WaitNext; /* 56 */
|
||||||
UCHAR WaitReason; /* 57 */
|
UCHAR WaitReason; /* 57 */
|
||||||
PKWAIT_BLOCK WaitBlockList; /* 58 */
|
PKWAIT_BLOCK WaitBlockList; /* 58 */
|
||||||
|
@ -114,12 +114,12 @@ typedef struct _KTHREAD
|
||||||
UCHAR Quantum; /* 6B */
|
UCHAR Quantum; /* 6B */
|
||||||
KWAIT_BLOCK WaitBlock[4]; /* 6C */
|
KWAIT_BLOCK WaitBlock[4]; /* 6C */
|
||||||
PVOID LegoData; /* CC */
|
PVOID LegoData; /* CC */
|
||||||
LONG KernelApcDisable; /* D0 */
|
ULONG KernelApcDisable; /* D0 */
|
||||||
KAFFINITY UserAffinity; /* D4 */
|
KAFFINITY UserAffinity; /* D4 */
|
||||||
UCHAR SystemAffinityActive;/* D8 */
|
UCHAR SystemAffinityActive;/* D8 */
|
||||||
UCHAR PowerState; /* D9 */
|
UCHAR PowerState; /* D9 */
|
||||||
UCHAR NpxIrql; /* DA */
|
UCHAR NpxIrql; /* DA */
|
||||||
UCHAR Pad; /* DB */
|
UCHAR Pad[1]; /* DB */
|
||||||
SSDT_ENTRY *ServiceTable; /* DC */
|
SSDT_ENTRY *ServiceTable; /* DC */
|
||||||
PKQUEUE Queue; /* E0 */
|
PKQUEUE Queue; /* E0 */
|
||||||
KSPIN_LOCK ApcQueueLock; /* E4 */
|
KSPIN_LOCK ApcQueueLock; /* E4 */
|
||||||
|
@ -131,7 +131,7 @@ typedef struct _KTHREAD
|
||||||
UCHAR KernelStackResident; /* 11E */
|
UCHAR KernelStackResident; /* 11E */
|
||||||
UCHAR NextProcessor; /* 11F */
|
UCHAR NextProcessor; /* 11F */
|
||||||
PVOID CallbackStack; /* 120 */
|
PVOID CallbackStack; /* 120 */
|
||||||
BOOL Win32Thread; /* 124 */
|
struct _W32THREAD *Win32Thread; /* 124 */
|
||||||
struct _KTRAP_FRAME *TrapFrame; /* 128 */
|
struct _KTRAP_FRAME *TrapFrame; /* 128 */
|
||||||
PKAPC_STATE ApcStatePointer[2]; /* 12C */
|
PKAPC_STATE ApcStatePointer[2]; /* 12C */
|
||||||
UCHAR EnableStackSwap; /* 134 */
|
UCHAR EnableStackSwap; /* 134 */
|
||||||
|
@ -153,13 +153,6 @@ typedef struct _KTHREAD
|
||||||
UCHAR SuspendCount; /* 1AD */
|
UCHAR SuspendCount; /* 1AD */
|
||||||
UCHAR IdealProcessor; /* 1AE */
|
UCHAR IdealProcessor; /* 1AE */
|
||||||
UCHAR DisableBoost; /* 1AF */
|
UCHAR DisableBoost; /* 1AF */
|
||||||
|
|
||||||
/*
|
|
||||||
* Below here are thread structure members that are specific to ReactOS
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Added by Phillip Susi for list of threads in a process */
|
|
||||||
LIST_ENTRY ProcessThreadListEntry; /* 1B0 */
|
|
||||||
} KTHREAD;
|
} KTHREAD;
|
||||||
|
|
||||||
#include <poppack.h>
|
#include <poppack.h>
|
||||||
|
@ -171,63 +164,61 @@ typedef struct _KTHREAD
|
||||||
#define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
|
#define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
|
||||||
#define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
|
#define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
|
||||||
|
|
||||||
|
#ifndef __USE_W32API
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
PACCESS_TOKEN Token; // 0x0
|
PACCESS_TOKEN Token;
|
||||||
BOOLEAN CopyOnOpen; // 0x4
|
BOOLEAN CopyOnOpen;
|
||||||
BOOLEAN EffectiveOnly; // 0x5
|
BOOLEAN EffectiveOnly;
|
||||||
UCHAR Pad[2]; // 0x6
|
SECURITY_IMPERSONATION_LEVEL Level;
|
||||||
SECURITY_IMPERSONATION_LEVEL Level; // 0x8
|
} PS_IMPERSONATION_INFORMATION, *PPS_IMPERSONATION_INFORMATION;
|
||||||
} PS_IMPERSONATION_INFO, *PPS_IMPERSONATION_INFO;
|
#endif
|
||||||
|
|
||||||
#include <pshpack1.h>
|
#include <pshpack1.h>
|
||||||
|
|
||||||
typedef struct _ETHREAD
|
typedef struct _ETHREAD
|
||||||
{
|
{
|
||||||
KTHREAD Tcb; /* 000 */
|
KTHREAD Tcb;
|
||||||
TIME CreateTime; /* 1B0/1B8 */
|
TIME CreateTime;
|
||||||
union
|
USHORT NestedFaultCount;
|
||||||
{
|
UCHAR ApcNeeded;
|
||||||
TIME ExitTime; /* 1B8/1E4 */
|
TIME ExitTime;
|
||||||
LIST_ENTRY LpcReplyChain; /* 1B8/1E4 */
|
LIST_ENTRY LpcReplyChain;
|
||||||
} u1;
|
NTSTATUS ExitStatus;
|
||||||
NTSTATUS ExitStatus; /* 1C0/1EC */
|
PVOID OfsChain;
|
||||||
LIST_ENTRY PostBlockList; /* 1C4/1F0 */
|
LIST_ENTRY PostBlockList;
|
||||||
LIST_ENTRY TerminationPortList; /* 1CC/1F8 */
|
LIST_ENTRY TerminationPortList;
|
||||||
KSPIN_LOCK ActiveTimerListLock; /* 1D4/200 */
|
KSPIN_LOCK ActiveTimerListLock;
|
||||||
LIST_ENTRY ActiveTimerListHead; /* 1D8/204 */
|
LIST_ENTRY ActiveTimerListHead;
|
||||||
CLIENT_ID Cid; /* 1E0/20C */
|
CLIENT_ID Cid;
|
||||||
KSEMAPHORE LpcReplySemaphore; /* 1E8/214 */
|
KSEMAPHORE LpcReplySemaphore;
|
||||||
PVOID LpcReplyMessage; /* 1FC/228 */
|
PVOID LpcReplyMessage;
|
||||||
PLARGE_INTEGER LpcReplyMessageId; /* 200/22C */
|
ULONG LpcReplyMessageId;
|
||||||
ULONG PerformanceCounterLow; /* 204/230 */
|
ULONG PerformanceCountLow;
|
||||||
PPS_IMPERSONATION_INFO ImpersonationInfo; /* 208/234 */
|
PPS_IMPERSONATION_INFORMATION ImpersonationInfo;
|
||||||
LIST_ENTRY IrpList; /* 20C/238 */
|
LIST_ENTRY IrpList;
|
||||||
PIRP TopLevelIrp; /* 214/240 */
|
PIRP TopLevelIrp;
|
||||||
PDEVICE_OBJECT DeviceToVerify; /* 218/244 */
|
PDEVICE_OBJECT DeviceToVerify;
|
||||||
ULONG ReadClusterSize; /* 21C/248 */
|
ULONG ReadClusterSize;
|
||||||
UCHAR ForwardClusterOnly; /* 220/24C */
|
UCHAR ForwardClusterOnly;
|
||||||
UCHAR DisablePageFaultClustering; /* 221/24D */
|
UCHAR DisablePageFaultClustering;
|
||||||
UCHAR DeadThread; /* 222/24E */
|
UCHAR DeadThread;
|
||||||
UCHAR HasTerminated; /* 223/24F */
|
UCHAR HideFromDebugger;
|
||||||
PVOID EventPair; /* 224/250 */
|
ULONG HasTerminated;
|
||||||
ACCESS_MASK GrantedAccess; /* 228/254 */
|
#ifdef _ENABLE_THRDEVTPAIR
|
||||||
struct _EPROCESS* ThreadsProcess; /* 22C/258 */
|
PVOID EventPair;
|
||||||
PKSTART_ROUTINE StartAddress; /* 230/25C */
|
#endif /* _ENABLE_THRDEVTPAIR */
|
||||||
union
|
ACCESS_MASK GrantedAccess;
|
||||||
{
|
struct _EPROCESS *ThreadsProcess;
|
||||||
LPTHREAD_START_ROUTINE Win32StartAddress; /* 234/260 */
|
PKSTART_ROUTINE StartAddress;
|
||||||
ULONG LpcReceiveMessageId; /* 234/260 */
|
LPTHREAD_START_ROUTINE Win32StartAddress;
|
||||||
} u2;
|
ULONG LpcReceivedMessageId;
|
||||||
UCHAR LpcExitThreadCalled; /* 238/264 */
|
UCHAR LpcExitThreadCalled;
|
||||||
UCHAR HardErrorsAreDisabled; /* 239/265 */
|
UCHAR HardErrorsAreDisabled;
|
||||||
UCHAR LpcReceivedMsgIdValid; /* 23A/266 */
|
UCHAR LpcReceivedMsgIdValid;
|
||||||
BOOLEAN ActiveImpersonationInfo; /* 23B/267 */
|
UCHAR ActiveImpersonationInfo;
|
||||||
ULONG PerformanceCountHigh; /* 23C/268 */
|
ULONG PerformanceCountHigh;
|
||||||
|
LIST_ENTRY ThreadListEntry;
|
||||||
|
|
||||||
struct _W32THREAD* Win32Thread;
|
|
||||||
|
|
||||||
} ETHREAD;
|
} ETHREAD;
|
||||||
|
|
||||||
#include <poppack.h>
|
#include <poppack.h>
|
||||||
|
@ -459,8 +450,10 @@ NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process, NTSTATUS ExitStatus);
|
||||||
VOID PiInitApcManagement(VOID);
|
VOID PiInitApcManagement(VOID);
|
||||||
VOID STDCALL PiDeleteThread(PVOID ObjectBody);
|
VOID STDCALL PiDeleteThread(PVOID ObjectBody);
|
||||||
VOID PsReapThreads(VOID);
|
VOID PsReapThreads(VOID);
|
||||||
|
VOID PsInitializeThreadReaper(VOID);
|
||||||
|
VOID PsQueueThreadReap(PETHREAD Thread);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
PsInitializeThread(HANDLE ProcessHandle,
|
PsInitializeThread(PEPROCESS Process,
|
||||||
PETHREAD* ThreadPtr,
|
PETHREAD* ThreadPtr,
|
||||||
PHANDLE ThreadHandle,
|
PHANDLE ThreadHandle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
|
@ -503,7 +496,7 @@ NTSTATUS PsResumeThread(PETHREAD Thread, PULONG PreviousCount);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First);
|
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First);
|
||||||
NTSTATUS KeReleaseThread(PETHREAD Thread);
|
NTSTATUS KeReleaseThread(PKTHREAD Thread);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
|
@ -520,6 +513,8 @@ KeUnstackDetachProcess (
|
||||||
|
|
||||||
VOID STDCALL PiDeleteProcess(PVOID ObjectBody);
|
VOID STDCALL PiDeleteProcess(PVOID ObjectBody);
|
||||||
VOID PsReapThreads(VOID);
|
VOID PsReapThreads(VOID);
|
||||||
|
VOID PsInitializeThreadReaper(VOID);
|
||||||
|
VOID PsQueueThreadReap(PETHREAD Thread);
|
||||||
VOID PsUnfreezeOtherThread(PETHREAD Thread);
|
VOID PsUnfreezeOtherThread(PETHREAD Thread);
|
||||||
VOID PsFreezeOtherThread(PETHREAD Thread);
|
VOID PsFreezeOtherThread(PETHREAD Thread);
|
||||||
VOID PsFreezeProcessThreads(PEPROCESS Process);
|
VOID PsFreezeProcessThreads(PEPROCESS Process);
|
||||||
|
@ -555,8 +550,7 @@ PsDispatchThread(ULONG NewThreadStatus);
|
||||||
VOID
|
VOID
|
||||||
PsInitialiseSuspendImplementation(VOID);
|
PsInitialiseSuspendImplementation(VOID);
|
||||||
|
|
||||||
extern ULONG PiNrThreadsAwaitingReaping;
|
extern LONG PiNrThreadsAwaitingReaping;
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
PsInitWin32Thread (PETHREAD Thread);
|
PsInitWin32Thread (PETHREAD Thread);
|
||||||
|
@ -643,6 +637,32 @@ typedef struct _EJOB
|
||||||
|
|
||||||
VOID INIT_FUNCTION PsInitJobManagment(VOID);
|
VOID INIT_FUNCTION PsInitJobManagment(VOID);
|
||||||
|
|
||||||
|
/* CID */
|
||||||
|
|
||||||
|
typedef struct _CID_OBJECT
|
||||||
|
{
|
||||||
|
LONG ref;
|
||||||
|
HANDLE Handle;
|
||||||
|
LIST_ENTRY Entry;
|
||||||
|
LONG Lock;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct _EPROCESS *Process;
|
||||||
|
struct _ETHREAD *Thread;
|
||||||
|
PVOID Object;
|
||||||
|
} Obj;
|
||||||
|
} CID_OBJECT, *PCID_OBJECT;
|
||||||
|
|
||||||
|
NTSTATUS PsCreateCidHandle(PVOID Object, POBJECT_TYPE ObjectType, PHANDLE Handle);
|
||||||
|
NTSTATUS PsDeleteCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType);
|
||||||
|
PCID_OBJECT PsLockCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType);
|
||||||
|
VOID PsUnlockCidObject(PCID_OBJECT CidObject);
|
||||||
|
|
||||||
|
#define ETHREAD_TO_KTHREAD(pEThread) (&(pEThread)->Tcb)
|
||||||
|
#define KTHREAD_TO_ETHREAD(pKThread) (CONTAINING_RECORD((pKThread), ETHREAD, Tcb))
|
||||||
|
#define EPROCESS_TO_KPROCESS(pEProcess) (&(pEProcess)->Pcb)
|
||||||
|
#define KPROCESS_TO_EPROCESS(pKProcess) (CONTAINING_RECORD((pKProcess), EPROCESS, Pcb))
|
||||||
|
|
||||||
#endif /* ASSEMBLER */
|
#endif /* ASSEMBLER */
|
||||||
|
|
||||||
#endif /* __INCLUDE_INTERNAL_PS_H */
|
#endif /* __INCLUDE_INTERNAL_PS_H */
|
||||||
|
|
|
@ -87,8 +87,6 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
extern LIST_ENTRY PiThreadListHead;
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
|
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
|
||||||
|
@ -108,6 +106,8 @@ static PETHREAD GspRunThread; /* NULL means run all threads */
|
||||||
static PETHREAD GspDbgThread;
|
static PETHREAD GspDbgThread;
|
||||||
static PETHREAD GspEnumThread;
|
static PETHREAD GspEnumThread;
|
||||||
|
|
||||||
|
extern LIST_ENTRY PsProcessListHead;
|
||||||
|
|
||||||
/* Number of Registers. */
|
/* Number of Registers. */
|
||||||
#define NUMREGS 16
|
#define NUMREGS 16
|
||||||
|
|
||||||
|
@ -650,14 +650,6 @@ GspFindThread(PCHAR Data,
|
||||||
/* All threads */
|
/* All threads */
|
||||||
ThreadInfo = NULL;
|
ThreadInfo = NULL;
|
||||||
}
|
}
|
||||||
else if (strcmp (Data, "0") == 0)
|
|
||||||
{
|
|
||||||
/* Pick any thread, pick the first thread,
|
|
||||||
* which is what most people are interested in
|
|
||||||
*/
|
|
||||||
ThreadInfo = CONTAINING_RECORD (PiThreadListHead.Flink,
|
|
||||||
ETHREAD, Tcb.ThreadListEntry);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ULONG ThreadId;
|
ULONG ThreadId;
|
||||||
|
@ -747,24 +739,76 @@ GspQuery(PCHAR Request)
|
||||||
}
|
}
|
||||||
else if (strncmp (Command, "fThreadInfo", 11) == 0)
|
else if (strncmp (Command, "fThreadInfo", 11) == 0)
|
||||||
{
|
{
|
||||||
|
PEPROCESS Process;
|
||||||
|
PLIST_ENTRY AThread, AProcess;
|
||||||
PCHAR ptr = &GspOutBuffer[1];
|
PCHAR ptr = &GspOutBuffer[1];
|
||||||
|
|
||||||
/* Get first thread id */
|
/* Get first thread id */
|
||||||
|
GspEnumThread = NULL;
|
||||||
|
AProcess = PsProcessListHead.Flink;
|
||||||
|
while(AProcess != &PsProcessListHead)
|
||||||
|
{
|
||||||
|
Process = CONTAINING_RECORD(AProcess, EPROCESS, ProcessListEntry);
|
||||||
|
AThread = Process->ThreadListHead.Flink;
|
||||||
|
if(AThread != &Process->ThreadListHead)
|
||||||
|
{
|
||||||
|
GspEnumThread = CONTAINING_RECORD (Process->ThreadListHead.Flink,
|
||||||
|
ETHREAD, ThreadListEntry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
AProcess = AProcess->Flink;
|
||||||
|
}
|
||||||
|
if(GspEnumThread != NULL)
|
||||||
|
{
|
||||||
GspOutBuffer[0] = 'm';
|
GspOutBuffer[0] = 'm';
|
||||||
GspEnumThread = CONTAINING_RECORD (PiThreadListHead.Flink,
|
|
||||||
ETHREAD, Tcb.ThreadListEntry);
|
|
||||||
Value = (ULONG) GspEnumThread->Cid.UniqueThread;
|
Value = (ULONG) GspEnumThread->Cid.UniqueThread;
|
||||||
GspLong2Hex (&ptr, Value);
|
GspLong2Hex (&ptr, Value);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* FIXME - what to do here? This case should never happen though, there
|
||||||
|
should always be at least one thread on the system... */
|
||||||
|
/* GspOutBuffer[0] = 'l'; */
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (strncmp (Command, "sThreadInfo", 11) == 0)
|
else if (strncmp (Command, "sThreadInfo", 11) == 0)
|
||||||
{
|
{
|
||||||
|
PEPROCESS Process;
|
||||||
|
PLIST_ENTRY AThread, AProcess;
|
||||||
PCHAR ptr = &GspOutBuffer[1];
|
PCHAR ptr = &GspOutBuffer[1];
|
||||||
|
|
||||||
/* Get next thread id */
|
/* Get next thread id */
|
||||||
if ((GspEnumThread) && (GspEnumThread->Tcb.ThreadListEntry.Flink != PiThreadListHead.Flink))
|
if (GspEnumThread != NULL)
|
||||||
{
|
{
|
||||||
GspEnumThread = CONTAINING_RECORD (GspEnumThread->Tcb.ThreadListEntry.Flink,
|
/* find the next thread */
|
||||||
ETHREAD, Tcb.ThreadListEntry);
|
Process = GspEnumThread->ThreadsProcess;
|
||||||
|
if(GspEnumThread->ThreadListEntry.Flink != &Process->ThreadListHead)
|
||||||
|
{
|
||||||
|
GspEnumThread = CONTAINING_RECORD (GspEnumThread->ThreadListEntry.Flink,
|
||||||
|
ETHREAD, ThreadListEntry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PETHREAD Thread = NULL;
|
||||||
|
AProcess = Process->ProcessListEntry.Flink;
|
||||||
|
while(AProcess != &PsProcessListHead)
|
||||||
|
{
|
||||||
|
Process = CONTAINING_RECORD(AProcess, EPROCESS, ProcessListEntry);
|
||||||
|
AThread = Process->ThreadListHead.Flink;
|
||||||
|
if(AThread != &Process->ThreadListHead)
|
||||||
|
{
|
||||||
|
Thread = CONTAINING_RECORD (Process->ThreadListHead.Flink,
|
||||||
|
ETHREAD, ThreadListEntry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
AProcess = AProcess->Flink;
|
||||||
|
}
|
||||||
|
GspEnumThread = Thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(GspEnumThread != NULL)
|
||||||
|
{
|
||||||
|
/* return the ID */
|
||||||
GspOutBuffer[0] = 'm';
|
GspOutBuffer[0] = 'm';
|
||||||
Value = (ULONG) GspEnumThread->Cid.UniqueThread;
|
Value = (ULONG) GspEnumThread->Cid.UniqueThread;
|
||||||
GspLong2Hex (&ptr, Value);
|
GspLong2Hex (&ptr, Value);
|
||||||
|
@ -774,6 +818,11 @@ GspQuery(PCHAR Request)
|
||||||
GspOutBuffer[0] = 'l';
|
GspOutBuffer[0] = 'l';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GspOutBuffer[0] = 'l';
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (strncmp (Command, "ThreadExtraInfo", 15) == 0)
|
else if (strncmp (Command, "ThreadExtraInfo", 15) == 0)
|
||||||
{
|
{
|
||||||
PETHREAD ThreadInfo;
|
PETHREAD ThreadInfo;
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
KSPIN_LOCK PiApcLock;
|
KSPIN_LOCK PiApcLock;
|
||||||
extern KSPIN_LOCK PiThreadListLock;
|
|
||||||
|
|
||||||
VOID PsTerminateCurrentThread(NTSTATUS ExitStatus);
|
VOID PsTerminateCurrentThread(NTSTATUS ExitStatus);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: bug.c,v 1.45 2004/08/15 16:39:05 chorns Exp $
|
/* $Id: bug.c,v 1.46 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ke/bug.c
|
* FILE: ntoskrnl/ke/bug.c
|
||||||
|
@ -40,8 +40,6 @@
|
||||||
static LIST_ENTRY BugcheckCallbackListHead = {NULL,NULL};
|
static LIST_ENTRY BugcheckCallbackListHead = {NULL,NULL};
|
||||||
static ULONG InBugCheck;
|
static ULONG InBugCheck;
|
||||||
|
|
||||||
VOID PsDumpThreads(VOID);
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID INIT_FUNCTION
|
VOID INIT_FUNCTION
|
||||||
|
|
|
@ -158,7 +158,7 @@ _Ki386ContextSwitch:
|
||||||
*/
|
*/
|
||||||
sti
|
sti
|
||||||
|
|
||||||
push $_PiThreadListLock
|
push $_PiThreadLock
|
||||||
call _KeReleaseSpinLockFromDpcLevel@4
|
call _KeReleaseSpinLockFromDpcLevel@4
|
||||||
|
|
||||||
cmpl $0, _PiNrThreadsAwaitingReaping
|
cmpl $0, _PiNrThreadsAwaitingReaping
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: kthread.c,v 1.52 2004/08/27 10:24:04 hbirr Exp $
|
/* $Id: kthread.c,v 1.53 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* FILE: ntoskrnl/ke/kthread.c
|
* FILE: ntoskrnl/ke/kthread.c
|
||||||
* PURPOSE: Microkernel thread support
|
* PURPOSE: Microkernel thread support
|
||||||
|
@ -76,7 +76,7 @@ KeQueryPriorityThread (
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
KeReleaseThread(PETHREAD Thread)
|
KeReleaseThread(PKTHREAD Thread)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Releases the resource allocated for a thread by
|
* FUNCTION: Releases the resource allocated for a thread by
|
||||||
* KeInitializeThread
|
* KeInitializeThread
|
||||||
|
@ -85,20 +85,23 @@ KeReleaseThread(PETHREAD Thread)
|
||||||
{
|
{
|
||||||
extern unsigned int init_stack;
|
extern unsigned int init_stack;
|
||||||
|
|
||||||
if (Thread->Tcb.StackLimit != (ULONG)&init_stack)
|
/* FIXME - lock the process */
|
||||||
|
RemoveEntryList(&Thread->ThreadListEntry);
|
||||||
|
|
||||||
|
if (Thread->StackLimit != (ULONG)&init_stack)
|
||||||
{
|
{
|
||||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||||
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||||
(PVOID)Thread->Tcb.StackLimit,
|
(PVOID)Thread->StackLimit,
|
||||||
MM_STACK_SIZE,
|
MM_STACK_SIZE,
|
||||||
KeFreeStackPage,
|
KeFreeStackPage,
|
||||||
NULL);
|
NULL);
|
||||||
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
||||||
}
|
}
|
||||||
Thread->Tcb.StackLimit = 0;
|
Thread->StackLimit = 0;
|
||||||
Thread->Tcb.InitialStack = NULL;
|
Thread->InitialStack = NULL;
|
||||||
Thread->Tcb.StackBase = NULL;
|
Thread->StackBase = NULL;
|
||||||
Thread->Tcb.KernelStack = NULL;
|
Thread->KernelStack = NULL;
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +277,7 @@ crashes. I'm disabling it again, until we fix the APC implementation...
|
||||||
Thread->KernelStackResident = 1;
|
Thread->KernelStackResident = 1;
|
||||||
Thread->NextProcessor = 0;
|
Thread->NextProcessor = 0;
|
||||||
Thread->CallbackStack = NULL;
|
Thread->CallbackStack = NULL;
|
||||||
Thread->Win32Thread = 0;
|
Thread->Win32Thread = NULL;
|
||||||
Thread->TrapFrame = NULL;
|
Thread->TrapFrame = NULL;
|
||||||
Thread->ApcStatePointer[OriginalApcEnvironment] = &Thread->ApcState;
|
Thread->ApcStatePointer[OriginalApcEnvironment] = &Thread->ApcState;
|
||||||
Thread->ApcStatePointer[AttachedApcEnvironment] = &Thread->SavedApcState;
|
Thread->ApcStatePointer[AttachedApcEnvironment] = &Thread->SavedApcState;
|
||||||
|
@ -304,17 +307,11 @@ crashes. I'm disabling it again, until we fix the APC implementation...
|
||||||
KernelMode,
|
KernelMode,
|
||||||
NULL);
|
NULL);
|
||||||
KeInitializeSemaphore(&Thread->SuspendSemaphore, 0, 128);
|
KeInitializeSemaphore(&Thread->SuspendSemaphore, 0, 128);
|
||||||
Thread->ThreadListEntry.Flink = NULL;
|
InsertTailList(&Process->ThreadListHead,
|
||||||
Thread->ThreadListEntry.Blink = NULL;
|
&Thread->ThreadListEntry);
|
||||||
Thread->FreezeCount = 0;
|
Thread->FreezeCount = 0;
|
||||||
Thread->SuspendCount = 0;
|
Thread->SuspendCount = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize ReactOS specific members
|
|
||||||
*/
|
|
||||||
Thread->ProcessThreadListEntry.Flink = NULL;
|
|
||||||
Thread->ProcessThreadListEntry.Blink = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do x86 specific part
|
* Do x86 specific part
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: timer.c,v 1.77 2004/08/21 21:19:06 tamlin Exp $
|
/* $Id: timer.c,v 1.78 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -65,7 +65,6 @@ static KDPC ExpireTimerDpc;
|
||||||
|
|
||||||
/* must raise IRQL to PROFILE_LEVEL and grab spin lock there, to sync with ISR */
|
/* must raise IRQL to PROFILE_LEVEL and grab spin lock there, to sync with ISR */
|
||||||
|
|
||||||
extern ULONG PiNrRunnableThreads;
|
|
||||||
extern HANDLE PsIdleThreadHandle;
|
extern HANDLE PsIdleThreadHandle;
|
||||||
|
|
||||||
#define MICROSECONDS_PER_TICK (10000)
|
#define MICROSECONDS_PER_TICK (10000)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: evtpair.c,v 1.22 2004/08/15 16:39:09 chorns Exp $
|
/* $Id: evtpair.c,v 1.23 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -330,6 +330,8 @@ NtWaitHighEventPair(IN HANDLE EventPairHandle)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _ENABLE_THRDEVTPAIR
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Author: Skywing (skywing@valhallalegends.com), 09/08/2003
|
* Author: Skywing (skywing@valhallalegends.com), 09/08/2003
|
||||||
* Note that the eventpair spinlock must be acquired when setting the thread
|
* Note that the eventpair spinlock must be acquired when setting the thread
|
||||||
|
@ -465,4 +467,30 @@ ExpSwapThreadEventPair(
|
||||||
KeReleaseSpinLock(&ExThreadEventPairSpinLock, Irql);
|
KeReleaseSpinLock(&ExThreadEventPairSpinLock, Irql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* !_ENABLE_THRDEVTPAIR */
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTSYSAPI
|
||||||
|
NTAPI
|
||||||
|
NtSetLowWaitHighThread(
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DPRINT1("NtSetLowWaitHighThread() not supported anymore (NT4 only)!\n");
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTSYSAPI
|
||||||
|
NTAPI
|
||||||
|
NtSetHighWaitLowThread(
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DPRINT1("NtSetHighWaitLowThread() not supported anymore (NT4 only)!\n");
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _ENABLE_THRDEVTPAIR */
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: handle.c,v 1.61 2004/09/24 16:18:28 weiden Exp $
|
/* $Id: handle.c,v 1.62 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -414,11 +414,13 @@ VOID ObCloseAllHandles(PEPROCESS Process)
|
||||||
{
|
{
|
||||||
POBJECT_HEADER Header = BODY_TO_HEADER(ObjectBody);
|
POBJECT_HEADER Header = BODY_TO_HEADER(ObjectBody);
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (Header->ObjectType == PsProcessType ||
|
if (Header->ObjectType == PsProcessType ||
|
||||||
Header->ObjectType == PsThreadType)
|
Header->ObjectType == PsThreadType)
|
||||||
{
|
{
|
||||||
DPRINT("Deleting handle to %x\n", ObjectBody);
|
DPRINT("Deleting handle to %x\n", ObjectBody);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ObReferenceObjectByPointer(ObjectBody,
|
ObReferenceObjectByPointer(ObjectBody,
|
||||||
0,
|
0,
|
||||||
|
|
183
reactos/ntoskrnl/ps/cid.c
Normal file
183
reactos/ntoskrnl/ps/cid.c
Normal file
|
@ -0,0 +1,183 @@
|
||||||
|
/* $Id: cid.c,v 1.1 2004/09/28 15:02:29 weiden Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/ps/clientid.c
|
||||||
|
* PURPOSE: Client ID (CID) management
|
||||||
|
* PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
|
||||||
|
* REVISION HISTORY:
|
||||||
|
* 9/20/2004: Created
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
|
#include <ntoskrnl.h>
|
||||||
|
#define NDEBUG
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME - use a global handle table instead!
|
||||||
|
*/
|
||||||
|
|
||||||
|
KSPIN_LOCK CidLock;
|
||||||
|
LIST_ENTRY CidHead;
|
||||||
|
KEVENT CidReleaseEvent;
|
||||||
|
LONG CidCounter = 0;
|
||||||
|
LARGE_INTEGER ShortDelay, LongDelay;
|
||||||
|
|
||||||
|
#define TAG_CIDOBJECT TAG('C', 'I', 'D', 'O')
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID INIT_FUNCTION
|
||||||
|
PsInitClientIDManagment(VOID)
|
||||||
|
{
|
||||||
|
InitializeListHead(&CidHead);
|
||||||
|
KeInitializeSpinLock(&CidLock);
|
||||||
|
KeInitializeEvent(&CidReleaseEvent, SynchronizationEvent, FALSE);
|
||||||
|
ShortDelay.QuadPart = -100LL;
|
||||||
|
LongDelay.QuadPart = -100000LL;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
PspReferenceCidObject(PCID_OBJECT Object)
|
||||||
|
{
|
||||||
|
InterlockedIncrement(&Object->ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
PspDereferenceCidObject(PCID_OBJECT Object)
|
||||||
|
{
|
||||||
|
if(InterlockedDecrement(&Object->ref) == 0)
|
||||||
|
{
|
||||||
|
ExFreePool(Object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
PsCreateCidHandle(PVOID Object, POBJECT_TYPE ObjectType, PHANDLE Handle)
|
||||||
|
{
|
||||||
|
KIRQL oldIrql;
|
||||||
|
PCID_OBJECT cido = ExAllocatePoolWithTag(NonPagedPool,
|
||||||
|
sizeof(CID_OBJECT),
|
||||||
|
TAG_CIDOBJECT);
|
||||||
|
if(cido != NULL)
|
||||||
|
{
|
||||||
|
cido->ref = 1;
|
||||||
|
cido->Lock = 0;
|
||||||
|
cido->Obj.Object = Object;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&CidLock, &oldIrql);
|
||||||
|
cido->Handle = (HANDLE)(++CidCounter);
|
||||||
|
InsertTailList(&CidHead, &cido->Entry);
|
||||||
|
KeReleaseSpinLock(&CidLock, oldIrql);
|
||||||
|
|
||||||
|
*Handle = cido->Handle;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
PsDeleteCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType)
|
||||||
|
{
|
||||||
|
PCID_OBJECT cido, Found = NULL;
|
||||||
|
PLIST_ENTRY Current;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
|
||||||
|
if(CidHandle == NULL)
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&CidLock, &oldIrql);
|
||||||
|
Current = CidHead.Flink;
|
||||||
|
while(Current != &CidHead)
|
||||||
|
{
|
||||||
|
cido = CONTAINING_RECORD(Current, CID_OBJECT, Entry);
|
||||||
|
if(cido->Handle == CidHandle)
|
||||||
|
{
|
||||||
|
RemoveEntryList(&cido->Entry);
|
||||||
|
cido->Handle = NULL;
|
||||||
|
Found = cido;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Current = Current->Flink;
|
||||||
|
}
|
||||||
|
KeReleaseSpinLock(&CidLock, oldIrql);
|
||||||
|
|
||||||
|
if(Found != NULL)
|
||||||
|
{
|
||||||
|
PspDereferenceCidObject(Found);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
PCID_OBJECT
|
||||||
|
PsLockCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType)
|
||||||
|
{
|
||||||
|
PCID_OBJECT cido, Found = NULL;
|
||||||
|
PLIST_ENTRY Current;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
|
||||||
|
if(CidHandle == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&CidLock, &oldIrql);
|
||||||
|
Current = CidHead.Flink;
|
||||||
|
while(Current != &CidHead)
|
||||||
|
{
|
||||||
|
cido = CONTAINING_RECORD(Current, CID_OBJECT, Entry);
|
||||||
|
if(cido->Handle == CidHandle)
|
||||||
|
{
|
||||||
|
Found = cido;
|
||||||
|
PspReferenceCidObject(Found);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Current = Current->Flink;
|
||||||
|
}
|
||||||
|
KeReleaseSpinLock(&CidLock, oldIrql);
|
||||||
|
|
||||||
|
if(Found != NULL)
|
||||||
|
{
|
||||||
|
BOOL GotLock;
|
||||||
|
ULONG Attempt = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(InterlockedCompareExchange(&Found->Lock, 1, 0) == 0)
|
||||||
|
{
|
||||||
|
/* got the lock, bail */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Attempt++ >= 1)
|
||||||
|
{
|
||||||
|
/* wait a little longer */
|
||||||
|
KeDelayExecutionThread(KernelMode, FALSE, &LongDelay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* try again, just wait shortly */
|
||||||
|
KeDelayExecutionThread(KernelMode, FALSE, &ShortDelay);
|
||||||
|
}
|
||||||
|
} while(!GotLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Found;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
PsUnlockCidObject(PCID_OBJECT CidObject)
|
||||||
|
{
|
||||||
|
InterlockedExchange(&CidObject->Lock, 0);
|
||||||
|
PspDereferenceCidObject(CidObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.80 2004/08/31 06:08:38 navaraf Exp $
|
/* $Id: create.c,v 1.81 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -27,12 +27,7 @@
|
||||||
|
|
||||||
/* GLOBAL *******************************************************************/
|
/* GLOBAL *******************************************************************/
|
||||||
|
|
||||||
static ULONG PiNextThreadUniqueId = 0;
|
extern KSPIN_LOCK PiThreadLock;
|
||||||
|
|
||||||
extern KSPIN_LOCK PiThreadListLock;
|
|
||||||
extern ULONG PiNrThreads;
|
|
||||||
|
|
||||||
extern LIST_ENTRY PiThreadListHead;
|
|
||||||
|
|
||||||
#define MAX_THREAD_NOTIFY_ROUTINE_COUNT 8
|
#define MAX_THREAD_NOTIFY_ROUTINE_COUNT 8
|
||||||
|
|
||||||
|
@ -138,7 +133,7 @@ PsImpersonateClient (IN PETHREAD Thread,
|
||||||
if (Thread->ImpersonationInfo == NULL)
|
if (Thread->ImpersonationInfo == NULL)
|
||||||
{
|
{
|
||||||
Thread->ImpersonationInfo = ExAllocatePool (NonPagedPool,
|
Thread->ImpersonationInfo = ExAllocatePool (NonPagedPool,
|
||||||
sizeof(PS_IMPERSONATION_INFO));
|
sizeof(PS_IMPERSONATION_INFORMATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread->ImpersonationInfo->Level = ImpersonationLevel;
|
Thread->ImpersonationInfo->Level = ImpersonationLevel;
|
||||||
|
@ -380,28 +375,28 @@ PiBeforeBeginThread(CONTEXT c)
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
PiDeleteThread(PVOID ObjectBody)
|
PiDeleteThread(PVOID ObjectBody)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
|
PEPROCESS Process;
|
||||||
|
|
||||||
Thread = (PETHREAD)ObjectBody;
|
Thread = (PETHREAD)ObjectBody;
|
||||||
|
|
||||||
DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
|
DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
|
||||||
|
|
||||||
ObDereferenceObject(Thread->ThreadsProcess);
|
Process = Thread->ThreadsProcess;
|
||||||
Thread->ThreadsProcess = NULL;
|
Thread->ThreadsProcess = NULL;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
PsDeleteCidHandle(Thread->Cid.UniqueThread, PsThreadType);
|
||||||
PiNrThreads--;
|
|
||||||
RemoveEntryList(&Thread->Tcb.ThreadListEntry);
|
KeReleaseThread(ETHREAD_TO_KTHREAD(Thread));
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
KeReleaseThread(Thread);
|
|
||||||
DPRINT("PiDeleteThread() finished\n");
|
DPRINT("PiDeleteThread() finished\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
PsInitializeThread(HANDLE ProcessHandle,
|
PsInitializeThread(PEPROCESS Process,
|
||||||
PETHREAD* ThreadPtr,
|
PETHREAD* ThreadPtr,
|
||||||
PHANDLE ThreadHandle,
|
PHANDLE ThreadHandle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
|
@ -411,34 +406,19 @@ PsInitializeThread(HANDLE ProcessHandle,
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
PEPROCESS Process;
|
|
||||||
|
if (Process == NULL)
|
||||||
|
{
|
||||||
|
Process = PsInitialSystemProcess;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reference process
|
* Reference process
|
||||||
*/
|
*/
|
||||||
if (ProcessHandle != NULL)
|
|
||||||
{
|
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
|
||||||
PROCESS_CREATE_THREAD,
|
|
||||||
PsProcessType,
|
|
||||||
UserMode,
|
|
||||||
(PVOID*)&Process,
|
|
||||||
NULL);
|
|
||||||
if (Status != STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
DPRINT("Failed at %s:%d\n",__FILE__,__LINE__);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
DPRINT( "Creating thread in process %x\n", Process );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Process = PsInitialSystemProcess;
|
|
||||||
ObReferenceObjectByPointer(Process,
|
ObReferenceObjectByPointer(Process,
|
||||||
PROCESS_CREATE_THREAD,
|
PROCESS_CREATE_THREAD,
|
||||||
PsProcessType,
|
PsProcessType,
|
||||||
UserMode);
|
KernelMode);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create and initialize thread
|
* Create and initialize thread
|
||||||
|
@ -454,9 +434,21 @@ PsInitializeThread(HANDLE ProcessHandle,
|
||||||
(PVOID*)&Thread);
|
(PVOID*)&Thread);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
ObDereferenceObject (Process);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* create a client id handle */
|
||||||
|
Status = PsCreateCidHandle(Thread, PsThreadType, &Thread->Cid.UniqueThread);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ObDereferenceObject (Thread);
|
||||||
|
ObDereferenceObject (Process);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
Thread->ThreadsProcess = Process;
|
||||||
|
Thread->Cid.UniqueProcess = (HANDLE)Thread->ThreadsProcess->UniqueProcessId;
|
||||||
|
|
||||||
Status = ObInsertObject ((PVOID)Thread,
|
Status = ObInsertObject ((PVOID)Thread,
|
||||||
NULL,
|
NULL,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
|
@ -466,27 +458,23 @@ PsInitializeThread(HANDLE ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ObDereferenceObject (Thread);
|
ObDereferenceObject (Thread);
|
||||||
|
ObDereferenceObject (Process);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Thread = %x\n",Thread);
|
DPRINT("Thread = %x\n",Thread);
|
||||||
|
|
||||||
PiNrThreads++;
|
|
||||||
|
|
||||||
KeInitializeThread(&Process->Pcb, &Thread->Tcb, First);
|
KeInitializeThread(&Process->Pcb, &Thread->Tcb, First);
|
||||||
Thread->ThreadsProcess = Process;
|
|
||||||
InitializeListHead(&Thread->TerminationPortList);
|
InitializeListHead(&Thread->TerminationPortList);
|
||||||
KeInitializeSpinLock(&Thread->ActiveTimerListLock);
|
KeInitializeSpinLock(&Thread->ActiveTimerListLock);
|
||||||
InitializeListHead(&Thread->IrpList);
|
InitializeListHead(&Thread->IrpList);
|
||||||
Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
|
Thread->DeadThread = FALSE;
|
||||||
(LONG *)&PiNextThreadUniqueId);
|
Thread->HasTerminated = FALSE;
|
||||||
Thread->Cid.UniqueProcess = (HANDLE)Thread->ThreadsProcess->UniqueProcessId;
|
Thread->Tcb.Win32Thread = NULL;
|
||||||
Thread->DeadThread = 0;
|
|
||||||
Thread->Win32Thread = 0;
|
|
||||||
DPRINT("Thread->Cid.UniqueThread %d\n",Thread->Cid.UniqueThread);
|
DPRINT("Thread->Cid.UniqueThread %d\n",Thread->Cid.UniqueThread);
|
||||||
|
|
||||||
|
|
||||||
Thread->Tcb.BasePriority = (CHAR)Thread->ThreadsProcess->Pcb.BasePriority;
|
Thread->Tcb.BasePriority = (CHAR)Process->Pcb.BasePriority;
|
||||||
Thread->Tcb.Priority = Thread->Tcb.BasePriority;
|
Thread->Tcb.Priority = Thread->Tcb.BasePriority;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -499,11 +487,10 @@ PsInitializeThread(HANDLE ProcessHandle,
|
||||||
Thread->LpcExitThreadCalled = FALSE;
|
Thread->LpcExitThreadCalled = FALSE;
|
||||||
Thread->LpcReceivedMsgIdValid = FALSE;
|
Thread->LpcReceivedMsgIdValid = FALSE;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
InsertTailList(&Thread->ThreadsProcess->ThreadListHead,
|
InsertTailList(&Process->ThreadListHead,
|
||||||
&Thread->Tcb.ProcessThreadListEntry);
|
&Thread->ThreadListEntry);
|
||||||
InsertTailList(&PiThreadListHead, &Thread->Tcb.ThreadListEntry);
|
KeReleaseSpinLock(&PiThreadLock, oldIrql);
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
|
|
||||||
*ThreadPtr = Thread;
|
*ThreadPtr = Thread;
|
||||||
|
|
||||||
|
@ -661,6 +648,7 @@ NtCreateThread(PHANDLE ThreadHandle,
|
||||||
PUSER_STACK UserStack,
|
PUSER_STACK UserStack,
|
||||||
BOOLEAN CreateSuspended)
|
BOOLEAN CreateSuspended)
|
||||||
{
|
{
|
||||||
|
PEPROCESS Process;
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
PTEB TebBase;
|
PTEB TebBase;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -669,12 +657,26 @@ NtCreateThread(PHANDLE ThreadHandle,
|
||||||
DPRINT("NtCreateThread(ThreadHandle %x, PCONTEXT %x)\n",
|
DPRINT("NtCreateThread(ThreadHandle %x, PCONTEXT %x)\n",
|
||||||
ThreadHandle,ThreadContext);
|
ThreadHandle,ThreadContext);
|
||||||
|
|
||||||
Status = PsInitializeThread(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
|
PROCESS_CREATE_THREAD,
|
||||||
|
PsProcessType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&Process,
|
||||||
|
NULL);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = PsInitializeThread(Process,
|
||||||
&Thread,
|
&Thread,
|
||||||
ThreadHandle,
|
ThreadHandle,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
ObjectAttributes,
|
ObjectAttributes,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
|
@ -778,7 +780,7 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
||||||
DPRINT("PsCreateSystemThread(ThreadHandle %x, ProcessHandle %x)\n",
|
DPRINT("PsCreateSystemThread(ThreadHandle %x, ProcessHandle %x)\n",
|
||||||
ThreadHandle,ProcessHandle);
|
ThreadHandle,ProcessHandle);
|
||||||
|
|
||||||
Status = PsInitializeThread(ProcessHandle,
|
Status = PsInitializeThread(NULL,
|
||||||
&Thread,
|
&Thread,
|
||||||
ThreadHandle,
|
ThreadHandle,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: kill.c,v 1.75 2004/09/14 18:37:40 gvg Exp $
|
/* $Id: kill.c,v 1.76 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -17,45 +17,78 @@
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
extern ULONG PiNrThreads;
|
extern KSPIN_LOCK PiThreadLock;
|
||||||
extern ULONG PiNrRunnableThreads;
|
|
||||||
extern KSPIN_LOCK PiThreadListLock;
|
|
||||||
extern LIST_ENTRY PiThreadListHead;
|
|
||||||
extern KSPIN_LOCK PiApcLock;
|
extern KSPIN_LOCK PiApcLock;
|
||||||
|
|
||||||
VOID PsTerminateCurrentThread(NTSTATUS ExitStatus);
|
VOID PsTerminateCurrentThread(NTSTATUS ExitStatus);
|
||||||
|
|
||||||
#define TAG_TERMINATE_APC TAG('T', 'A', 'P', 'C')
|
#define TAG_TERMINATE_APC TAG('T', 'A', 'P', 'C')
|
||||||
|
|
||||||
|
LIST_ENTRY ThreadsToReapHead;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID
|
||||||
|
PsInitializeThreadReaper(VOID)
|
||||||
|
{
|
||||||
|
InitializeListHead(&ThreadsToReapHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
PsReapThreads(VOID)
|
||||||
|
{
|
||||||
|
KIRQL oldlvl;
|
||||||
|
PETHREAD Thread;
|
||||||
|
PLIST_ENTRY ListEntry;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&PiThreadLock, &oldlvl);
|
||||||
|
while((ListEntry = RemoveHeadList(&ThreadsToReapHead)) != &ThreadsToReapHead)
|
||||||
|
{
|
||||||
|
PiNrThreadsAwaitingReaping--;
|
||||||
|
KeReleaseSpinLock(&PiThreadLock, oldlvl);
|
||||||
|
|
||||||
|
Thread = CONTAINING_RECORD(ListEntry, ETHREAD, TerminationPortList);
|
||||||
|
|
||||||
|
ObDereferenceObject(Thread);
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&PiThreadLock, &oldlvl);
|
||||||
|
}
|
||||||
|
KeReleaseSpinLock(&PiThreadLock, oldlvl);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
PsQueueThreadReap(PETHREAD Thread)
|
||||||
|
{
|
||||||
|
InsertTailList(&ThreadsToReapHead, &Thread->TerminationPortList);
|
||||||
|
PiNrThreadsAwaitingReaping++;
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
PiTerminateProcessThreads(PEPROCESS Process,
|
PiTerminateProcessThreads(PEPROCESS Process,
|
||||||
NTSTATUS ExitStatus)
|
NTSTATUS ExitStatus)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
PETHREAD current;
|
PETHREAD current, CurrentThread = PsGetCurrentThread();
|
||||||
|
|
||||||
DPRINT("PiTerminateProcessThreads(Process %x, ExitStatus %x)\n",
|
DPRINT("PiTerminateProcessThreads(Process %x, ExitStatus %x)\n",
|
||||||
Process, ExitStatus);
|
Process, ExitStatus);
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldlvl);
|
KeAcquireSpinLock(&PiThreadLock, &oldlvl);
|
||||||
|
|
||||||
current_entry = Process->ThreadListHead.Flink;
|
current_entry = Process->ThreadListHead.Flink;
|
||||||
while (current_entry != &Process->ThreadListHead)
|
while (current_entry != &Process->ThreadListHead)
|
||||||
{
|
{
|
||||||
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
||||||
Tcb.ProcessThreadListEntry);
|
ThreadListEntry);
|
||||||
if (current != PsGetCurrentThread() &&
|
if (current != CurrentThread && current->HasTerminated == 0)
|
||||||
current->DeadThread == 0)
|
|
||||||
{
|
{
|
||||||
DPRINT("Terminating %x, current thread: %x, "
|
DPRINT("Terminating %x, current thread: %x, "
|
||||||
"thread's process: %x\n", current, PsGetCurrentThread(),
|
"thread's process: %x\n", current, PsGetCurrentThread(),
|
||||||
current->ThreadsProcess);
|
current->ThreadsProcess);
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
|
KeReleaseSpinLock(&PiThreadLock, oldlvl);
|
||||||
PsTerminateOtherThread(current, ExitStatus);
|
PsTerminateOtherThread(current, ExitStatus);
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldlvl);
|
KeAcquireSpinLock(&PiThreadLock, &oldlvl);
|
||||||
current_entry = Process->ThreadListHead.Flink;
|
current_entry = Process->ThreadListHead.Flink;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -63,48 +96,10 @@ PiTerminateProcessThreads(PEPROCESS Process,
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
|
KeReleaseSpinLock(&PiThreadLock, oldlvl);
|
||||||
DPRINT("Finished PiTerminateProcessThreads()\n");
|
DPRINT("Finished PiTerminateProcessThreads()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
|
||||||
PsReapThreads(VOID)
|
|
||||||
{
|
|
||||||
PLIST_ENTRY current_entry;
|
|
||||||
PETHREAD current;
|
|
||||||
KIRQL oldIrql;
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
|
||||||
|
|
||||||
current_entry = PiThreadListHead.Flink;
|
|
||||||
|
|
||||||
while (current_entry != &PiThreadListHead)
|
|
||||||
{
|
|
||||||
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
|
||||||
Tcb.ThreadListEntry);
|
|
||||||
|
|
||||||
current_entry = current_entry->Flink;
|
|
||||||
|
|
||||||
if (current->Tcb.State == THREAD_STATE_TERMINATED_1)
|
|
||||||
{
|
|
||||||
PiNrThreadsAwaitingReaping--;
|
|
||||||
current->Tcb.State = THREAD_STATE_TERMINATED_2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
An unbelievably complex chain of events would cause a system crash
|
|
||||||
if PiThreadListLock was still held when the thread object is about
|
|
||||||
to be destroyed
|
|
||||||
*/
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
ObDereferenceObject(current);
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
|
||||||
|
|
||||||
current_entry = PiThreadListHead.Flink;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
/*
|
/*
|
||||||
|
@ -133,19 +128,19 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
(ULONG) CurrentThread);
|
(ULONG) CurrentThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
|
|
||||||
DPRINT("terminating %x\n",CurrentThread);
|
DPRINT("terminating %x\n",CurrentThread);
|
||||||
|
|
||||||
CurrentThread->ExitStatus = ExitStatus;
|
CurrentThread->ExitStatus = ExitStatus;
|
||||||
KeQuerySystemTime((PLARGE_INTEGER)&CurrentThread->u1.ExitTime);
|
KeQuerySystemTime((PLARGE_INTEGER)&CurrentThread->ExitTime);
|
||||||
KeCancelTimer(&CurrentThread->Tcb.Timer);
|
KeCancelTimer(&CurrentThread->Tcb.Timer);
|
||||||
|
|
||||||
/* Remove the thread from the thread list of its process */
|
/* Remove the thread from the thread list of its process */
|
||||||
RemoveEntryList(&CurrentThread->Tcb.ProcessThreadListEntry);
|
RemoveEntryList(&CurrentThread->ThreadListEntry);
|
||||||
Last = IsListEmpty(&CurrentProcess->ThreadListHead);
|
Last = IsListEmpty(&CurrentProcess->ThreadListHead);
|
||||||
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
KeReleaseSpinLock(&PiThreadLock, oldIrql);
|
||||||
|
|
||||||
/* Notify subsystems of the thread termination */
|
/* Notify subsystems of the thread termination */
|
||||||
PspRunCreateThreadNotifyRoutines(CurrentThread, FALSE);
|
PspRunCreateThreadNotifyRoutines(CurrentThread, FALSE);
|
||||||
|
@ -153,13 +148,12 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
|
|
||||||
/* Free the TEB */
|
/* Free the TEB */
|
||||||
if(CurrentThread->Tcb.Teb)
|
if(CurrentThread->Tcb.Teb)
|
||||||
ZwFreeVirtualMemory
|
{
|
||||||
(
|
ZwFreeVirtualMemory(NtCurrentProcess(),
|
||||||
NtCurrentProcess(),
|
|
||||||
(PVOID *)&CurrentThread->Tcb.Teb,
|
(PVOID *)&CurrentThread->Tcb.Teb,
|
||||||
&Length,
|
&Length,
|
||||||
MEM_RELEASE
|
MEM_RELEASE);
|
||||||
);
|
}
|
||||||
|
|
||||||
/* abandon all owned mutants */
|
/* abandon all owned mutants */
|
||||||
current_entry = CurrentThread->Tcb.MutantListHead.Flink;
|
current_entry = CurrentThread->Tcb.MutantListHead.Flink;
|
||||||
|
@ -187,9 +181,11 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
PiTerminateProcess(CurrentProcess, ExitStatus);
|
PiTerminateProcess(CurrentProcess, ExitStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
|
|
||||||
|
#ifdef _ENABLE_THRDEVTPAIR
|
||||||
ExpSwapThreadEventPair(CurrentThread, NULL); /* Release the associated eventpair object, if there was one */
|
ExpSwapThreadEventPair(CurrentThread, NULL); /* Release the associated eventpair object, if there was one */
|
||||||
|
#endif /* _ENABLE_THRDEVTPAIR */
|
||||||
KeRemoveAllWaitsThread (CurrentThread, STATUS_UNSUCCESSFUL, FALSE);
|
KeRemoveAllWaitsThread (CurrentThread, STATUS_UNSUCCESSFUL, FALSE);
|
||||||
|
|
||||||
PsDispatchThreadNoLock(THREAD_STATE_TERMINATED_1);
|
PsDispatchThreadNoLock(THREAD_STATE_TERMINATED_1);
|
||||||
|
@ -226,7 +222,7 @@ PsTerminateOtherThread(PETHREAD Thread,
|
||||||
NTSTATUS ExitStatus)
|
NTSTATUS ExitStatus)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Terminate a thread when calling from another thread's context
|
* FUNCTION: Terminate a thread when calling from another thread's context
|
||||||
* NOTES: This function must be called with PiThreadListLock held
|
* NOTES: This function must be called with PiThreadLock held
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PKAPC Apc;
|
PKAPC Apc;
|
||||||
|
@ -235,7 +231,7 @@ PsTerminateOtherThread(PETHREAD Thread,
|
||||||
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
||||||
Thread, ExitStatus);
|
Thread, ExitStatus);
|
||||||
|
|
||||||
Thread->DeadThread = 1;
|
Thread->HasTerminated = TRUE;
|
||||||
Thread->ExitStatus = ExitStatus;
|
Thread->ExitStatus = ExitStatus;
|
||||||
Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC);
|
Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC);
|
||||||
KeInitializeApc(Apc,
|
KeInitializeApc(Apc,
|
||||||
|
@ -321,6 +317,10 @@ NtTerminateProcess(IN HANDLE ProcessHandle,
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
PsTerminateCurrentThread(ExitStatus);
|
PsTerminateCurrentThread(ExitStatus);
|
||||||
|
/*
|
||||||
|
* We should never get here!
|
||||||
|
*/
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
@ -345,15 +345,19 @@ NtTerminateThread(IN HANDLE ThreadHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObDereferenceObject(Thread);
|
|
||||||
|
|
||||||
if (Thread == PsGetCurrentThread())
|
if (Thread == PsGetCurrentThread())
|
||||||
{
|
{
|
||||||
|
/* dereference the thread object before we kill our thread */
|
||||||
|
ObDereferenceObject(Thread);
|
||||||
PsTerminateCurrentThread(ExitStatus);
|
PsTerminateCurrentThread(ExitStatus);
|
||||||
|
/*
|
||||||
|
* We should never get here!
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PsTerminateOtherThread(Thread, ExitStatus);
|
PsTerminateOtherThread(Thread, ExitStatus);
|
||||||
|
ObDereferenceObject(Thread);
|
||||||
}
|
}
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -392,6 +396,7 @@ NtCallTerminatePorts(PETHREAD Thread)
|
||||||
KeReleaseSpinLock(&Thread->ActiveTimerListLock, oldIrql);
|
KeReleaseSpinLock(&Thread->ActiveTimerListLock, oldIrql);
|
||||||
LpcSendTerminationPort(current->Port,
|
LpcSendTerminationPort(current->Port,
|
||||||
Thread->CreateTime);
|
Thread->CreateTime);
|
||||||
|
ExFreePool(current);
|
||||||
KeAcquireSpinLock(&Thread->ActiveTimerListLock, &oldIrql);
|
KeAcquireSpinLock(&Thread->ActiveTimerListLock, &oldIrql);
|
||||||
}
|
}
|
||||||
KeReleaseSpinLock(&Thread->ActiveTimerListLock, oldIrql);
|
KeReleaseSpinLock(&Thread->ActiveTimerListLock, oldIrql);
|
||||||
|
@ -419,6 +424,8 @@ NtRegisterThreadTerminatePort(HANDLE TerminationPortHandle)
|
||||||
}
|
}
|
||||||
|
|
||||||
Request = ExAllocatePool(NonPagedPool, sizeof(EPORT_TERMINATION_REQUEST));
|
Request = ExAllocatePool(NonPagedPool, sizeof(EPORT_TERMINATION_REQUEST));
|
||||||
|
if(Request != NULL)
|
||||||
|
{
|
||||||
Request->Port = TerminationPort;
|
Request->Port = TerminationPort;
|
||||||
Thread = PsGetCurrentThread();
|
Thread = PsGetCurrentThread();
|
||||||
KeAcquireSpinLock(&Thread->ActiveTimerListLock, &oldIrql);
|
KeAcquireSpinLock(&Thread->ActiveTimerListLock, &oldIrql);
|
||||||
|
@ -427,3 +434,9 @@ NtRegisterThreadTerminatePort(HANDLE TerminationPortHandle)
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ObDereferenceObject(TerminationPort);
|
||||||
|
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.141 2004/09/22 14:53:26 weiden Exp $
|
/* $Id: process.c,v 1.142 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -25,7 +25,7 @@ POBJECT_TYPE EXPORTED PsProcessType = NULL;
|
||||||
|
|
||||||
LIST_ENTRY PsProcessListHead;
|
LIST_ENTRY PsProcessListHead;
|
||||||
static KSPIN_LOCK PsProcessListLock;
|
static KSPIN_LOCK PsProcessListLock;
|
||||||
static ULONG PiNextProcessUniqueId = 0;
|
static ULONG PiNextProcessUniqueId = 0; /* TODO */
|
||||||
|
|
||||||
static GENERIC_MAPPING PiProcessMapping = {PROCESS_READ,
|
static GENERIC_MAPPING PiProcessMapping = {PROCESS_READ,
|
||||||
PROCESS_WRITE,
|
PROCESS_WRITE,
|
||||||
|
@ -296,6 +296,7 @@ PsInitProcessManagment(VOID)
|
||||||
PsInitialSystemProcess->Pcb.LdtDescriptor[0] = 0;
|
PsInitialSystemProcess->Pcb.LdtDescriptor[0] = 0;
|
||||||
PsInitialSystemProcess->Pcb.LdtDescriptor[1] = 0;
|
PsInitialSystemProcess->Pcb.LdtDescriptor[1] = 0;
|
||||||
PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIO_NORMAL;
|
PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIO_NORMAL;
|
||||||
|
InitializeListHead(&PsInitialSystemProcess->Pcb.ThreadListHead);
|
||||||
KeInitializeDispatcherHeader(&PsInitialSystemProcess->Pcb.DispatcherHeader,
|
KeInitializeDispatcherHeader(&PsInitialSystemProcess->Pcb.DispatcherHeader,
|
||||||
InternalProcessType,
|
InternalProcessType,
|
||||||
sizeof(EPROCESS),
|
sizeof(EPROCESS),
|
||||||
|
@ -318,7 +319,7 @@ PsInitProcessManagment(VOID)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PsInitialSystemProcess->UniqueProcessId =
|
PsInitialSystemProcess->UniqueProcessId =
|
||||||
InterlockedIncrement((LONG *)&PiNextProcessUniqueId);
|
InterlockedIncrement((LONG *)&PiNextProcessUniqueId); /* TODO */
|
||||||
PsInitialSystemProcess->Win32WindowStation = (HANDLE)0;
|
PsInitialSystemProcess->Win32WindowStation = (HANDLE)0;
|
||||||
PsInitialSystemProcess->Win32Desktop = (HANDLE)0;
|
PsInitialSystemProcess->Win32Desktop = (HANDLE)0;
|
||||||
|
|
||||||
|
@ -660,9 +661,10 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
|
||||||
KProcess->IopmOffset = 0xffff;
|
KProcess->IopmOffset = 0xffff;
|
||||||
KProcess->LdtDescriptor[0] = 0;
|
KProcess->LdtDescriptor[0] = 0;
|
||||||
KProcess->LdtDescriptor[1] = 0;
|
KProcess->LdtDescriptor[1] = 0;
|
||||||
|
InitializeListHead(&KProcess->ThreadListHead);
|
||||||
MmInitializeAddressSpace(Process,
|
MmInitializeAddressSpace(Process,
|
||||||
&Process->AddressSpace);
|
&Process->AddressSpace);
|
||||||
Process->UniqueProcessId = InterlockedIncrement((LONG *)&PiNextProcessUniqueId);
|
Process->UniqueProcessId = InterlockedIncrement((LONG *)&PiNextProcessUniqueId); /* TODO */
|
||||||
Process->InheritedFromUniqueProcessId =
|
Process->InheritedFromUniqueProcessId =
|
||||||
(HANDLE)ParentProcess->UniqueProcessId;
|
(HANDLE)ParentProcess->UniqueProcessId;
|
||||||
ObCreateHandleTable(ParentProcess,
|
ObCreateHandleTable(ParentProcess,
|
||||||
|
@ -1501,7 +1503,7 @@ PiQuerySystemProcessInformation(PVOID Buffer,
|
||||||
CurrentT = CONTAINING_RECORD(
|
CurrentT = CONTAINING_RECORD(
|
||||||
CurrentEntryT,
|
CurrentEntryT,
|
||||||
KTHREAD,
|
KTHREAD,
|
||||||
Tcb.ThreadListEntry
|
ThreadListEntry
|
||||||
);
|
);
|
||||||
/*
|
/*
|
||||||
* Write thread data.
|
* Write thread data.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: psmgr.c,v 1.22 2004/09/22 22:31:46 weiden Exp $
|
/* $Id: psmgr.c,v 1.23 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -13,6 +13,8 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
VOID INIT_FUNCTION PsInitClientIDManagment(VOID);
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
VOID PiShutdownProcessManager(VOID)
|
VOID PiShutdownProcessManager(VOID)
|
||||||
|
@ -25,6 +27,7 @@ VOID PiShutdownProcessManager(VOID)
|
||||||
VOID INIT_FUNCTION
|
VOID INIT_FUNCTION
|
||||||
PiInitProcessManager(VOID)
|
PiInitProcessManager(VOID)
|
||||||
{
|
{
|
||||||
|
PsInitClientIDManagment();
|
||||||
PsInitJobManagment();
|
PsInitJobManagment();
|
||||||
PsInitProcessManagment();
|
PsInitProcessManagment();
|
||||||
PsInitThreadManagment();
|
PsInitThreadManagment();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: thread.c,v 1.133 2004/08/19 21:56:17 hbirr Exp $
|
/* $Id: thread.c,v 1.134 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -28,24 +28,22 @@
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
|
extern LIST_ENTRY PsProcessListHead;
|
||||||
|
|
||||||
POBJECT_TYPE EXPORTED PsThreadType = NULL;
|
POBJECT_TYPE EXPORTED PsThreadType = NULL;
|
||||||
|
|
||||||
KSPIN_LOCK PiThreadListLock;
|
KSPIN_LOCK PiThreadLock;
|
||||||
|
LONG PiNrThreadsAwaitingReaping = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PURPOSE: List of threads associated with each priority level
|
* PURPOSE: List of threads associated with each priority level
|
||||||
*/
|
*/
|
||||||
LIST_ENTRY PiThreadListHead;
|
|
||||||
static LIST_ENTRY PriorityListHead[MAXIMUM_PRIORITY];
|
static LIST_ENTRY PriorityListHead[MAXIMUM_PRIORITY];
|
||||||
static ULONG PriorityListMask = 0;
|
static ULONG PriorityListMask = 0;
|
||||||
static BOOLEAN DoneInitYet = FALSE;
|
static BOOLEAN DoneInitYet = FALSE;
|
||||||
static PETHREAD IdleThreads[MAXIMUM_PROCESSORS];
|
static PETHREAD IdleThreads[MAXIMUM_PROCESSORS];
|
||||||
ULONG PiNrThreads = 0;
|
|
||||||
ULONG PiNrReadyThreads = 0;
|
|
||||||
static HANDLE PiReaperThreadHandle;
|
|
||||||
static KEVENT PiReaperThreadEvent;
|
static KEVENT PiReaperThreadEvent;
|
||||||
static BOOLEAN PiReaperThreadShouldTerminate = FALSE;
|
static BOOLEAN PiReaperThreadShouldTerminate = FALSE;
|
||||||
ULONG PiNrThreadsAwaitingReaping = 0;
|
|
||||||
|
|
||||||
static GENERIC_MAPPING PiThreadMapping = {THREAD_READ,
|
static GENERIC_MAPPING PiThreadMapping = {THREAD_READ,
|
||||||
THREAD_WRITE,
|
THREAD_WRITE,
|
||||||
|
@ -163,8 +161,9 @@ PsGetThreadWin32Thread(
|
||||||
PETHREAD Thread
|
PETHREAD Thread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return Thread->Win32Thread;
|
return Thread->Tcb.Win32Thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -207,7 +206,7 @@ PsGetCurrentThreadStackLimit (
|
||||||
BOOLEAN STDCALL
|
BOOLEAN STDCALL
|
||||||
PsIsThreadTerminating(IN PETHREAD Thread)
|
PsIsThreadTerminating(IN PETHREAD Thread)
|
||||||
{
|
{
|
||||||
return(Thread->DeadThread);
|
return (Thread->HasTerminated ? TRUE : FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -224,7 +223,7 @@ PsIsSystemThread(
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
STDCALL
|
STDCALL
|
||||||
|
@ -232,8 +231,7 @@ PsIsThreadImpersonating(
|
||||||
PETHREAD Thread
|
PETHREAD Thread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
return Thread->ActiveImpersonationInfo;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
|
@ -247,7 +245,6 @@ PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
|
||||||
}
|
}
|
||||||
InsertTailList(&PriorityListHead[Priority], &Thread->Tcb.QueueListEntry);
|
InsertTailList(&PriorityListHead[Priority], &Thread->Tcb.QueueListEntry);
|
||||||
PriorityListMask |= (1 << Priority);
|
PriorityListMask |= (1 << Priority);
|
||||||
PiNrReadyThreads++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID PsRemoveFromThreadList(PETHREAD Thread)
|
static VOID PsRemoveFromThreadList(PETHREAD Thread)
|
||||||
|
@ -258,52 +255,46 @@ static VOID PsRemoveFromThreadList(PETHREAD Thread)
|
||||||
{
|
{
|
||||||
PriorityListMask &= ~(1 << Thread->Tcb.Priority);
|
PriorityListMask &= ~(1 << Thread->Tcb.Priority);
|
||||||
}
|
}
|
||||||
PiNrReadyThreads--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID PsDumpThreads(BOOLEAN IncludeSystem)
|
VOID PsDumpThreads(BOOLEAN IncludeSystem)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY AThread, AProcess;
|
||||||
PETHREAD current;
|
PEPROCESS Process;
|
||||||
ULONG t;
|
PETHREAD Thread;
|
||||||
ULONG i;
|
ULONG nThreads = 0;
|
||||||
|
|
||||||
current_entry = PiThreadListHead.Flink;
|
AProcess = PsProcessListHead.Flink;
|
||||||
t = 0;
|
while(AProcess != &PsProcessListHead)
|
||||||
|
{
|
||||||
|
Process = CONTAINING_RECORD(AProcess, EPROCESS, ProcessListEntry);
|
||||||
|
/* FIXME - skip suspended, ... processes? */
|
||||||
|
if((Process != PsInitialSystemProcess) ||
|
||||||
|
(Process == PsInitialSystemProcess && IncludeSystem))
|
||||||
|
{
|
||||||
|
AThread = Process->ThreadListHead.Flink;
|
||||||
|
while(AThread != &Process->ThreadListHead)
|
||||||
|
{
|
||||||
|
Thread = CONTAINING_RECORD(AThread, ETHREAD, ThreadListEntry);
|
||||||
|
|
||||||
while (current_entry != &PiThreadListHead)
|
nThreads++;
|
||||||
|
DbgPrint("Thread->Tcb.State %d PID.TID %d.%d Name %.8s Stack: \n",
|
||||||
|
Thread->Tcb.State,
|
||||||
|
Thread->ThreadsProcess->UniqueProcessId,
|
||||||
|
Thread->Cid.UniqueThread,
|
||||||
|
Thread->ThreadsProcess->ImageFileName);
|
||||||
|
if(Thread->Tcb.State == THREAD_STATE_READY ||
|
||||||
|
Thread->Tcb.State == THREAD_STATE_SUSPENDED ||
|
||||||
|
Thread->Tcb.State == THREAD_STATE_BLOCKED)
|
||||||
{
|
{
|
||||||
PULONG Ebp;
|
ULONG i = 0;
|
||||||
PULONG Esp;
|
PULONG Esp = (PULONG)Thread->Tcb.KernelStack;
|
||||||
|
PULONG Ebp = (PULONG)Esp[3];
|
||||||
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
|
||||||
Tcb.ThreadListEntry);
|
|
||||||
t++;
|
|
||||||
if (t > PiNrThreads)
|
|
||||||
{
|
|
||||||
DbgPrint("Too many threads on list\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (IncludeSystem || current->ThreadsProcess->UniqueProcessId >= 6)
|
|
||||||
{
|
|
||||||
DbgPrint("current->Tcb.State %d PID.TID %d.%d Name %.8s Stack: \n",
|
|
||||||
current->Tcb.State,
|
|
||||||
current->ThreadsProcess->UniqueProcessId,
|
|
||||||
current->Cid.UniqueThread,
|
|
||||||
current->ThreadsProcess->ImageFileName);
|
|
||||||
if (current->Tcb.State == THREAD_STATE_READY ||
|
|
||||||
current->Tcb.State == THREAD_STATE_SUSPENDED ||
|
|
||||||
current->Tcb.State == THREAD_STATE_BLOCKED)
|
|
||||||
{
|
|
||||||
Esp = (PULONG)current->Tcb.KernelStack;
|
|
||||||
Ebp = (PULONG)Esp[3];
|
|
||||||
DbgPrint("Ebp 0x%.8X\n", Ebp);
|
DbgPrint("Ebp 0x%.8X\n", Ebp);
|
||||||
i = 0;
|
while(Ebp != 0 && Ebp >= (PULONG)Thread->Tcb.StackLimit)
|
||||||
while (Ebp != 0 && Ebp >= (PULONG)current->Tcb.StackLimit)
|
|
||||||
{
|
{
|
||||||
DbgPrint("%.8X %.8X%s", Ebp[0], Ebp[1],
|
DbgPrint("%.8X %.8X%s", Ebp[0], Ebp[1], (i % 8) == 7 ? "\n" : " ");
|
||||||
(i % 8) == 7 ? "\n" : " ");
|
|
||||||
Ebp = (PULONG)Ebp[0];
|
Ebp = (PULONG)Ebp[0];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -312,8 +303,10 @@ VOID PsDumpThreads(BOOLEAN IncludeSystem)
|
||||||
DbgPrint("\n");
|
DbgPrint("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AThread = AThread->Flink;
|
||||||
}
|
}
|
||||||
current_entry = current_entry->Flink;
|
}
|
||||||
|
AProcess = AProcess->Flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +352,7 @@ PiWakeupReaperThread(VOID)
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
PiReaperThreadMain(PVOID Ignored)
|
PiReaperThreadMain(PVOID Ignored)
|
||||||
{
|
{
|
||||||
while (1)
|
for(;;)
|
||||||
{
|
{
|
||||||
KeWaitForSingleObject(&PiReaperThreadEvent,
|
KeWaitForSingleObject(&PiReaperThreadEvent,
|
||||||
Executive,
|
Executive,
|
||||||
|
@ -386,14 +379,15 @@ VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
|
||||||
CurrentThread->Cid.UniqueThread, NewThreadStatus, CurrentThread->Tcb.State);
|
CurrentThread->Cid.UniqueThread, NewThreadStatus, CurrentThread->Tcb.State);
|
||||||
|
|
||||||
CurrentThread->Tcb.State = (UCHAR)NewThreadStatus;
|
CurrentThread->Tcb.State = (UCHAR)NewThreadStatus;
|
||||||
if (CurrentThread->Tcb.State == THREAD_STATE_READY)
|
switch(NewThreadStatus)
|
||||||
{
|
{
|
||||||
|
case THREAD_STATE_READY:
|
||||||
PsInsertIntoThreadList(CurrentThread->Tcb.Priority,
|
PsInsertIntoThreadList(CurrentThread->Tcb.Priority,
|
||||||
CurrentThread);
|
CurrentThread);
|
||||||
}
|
break;
|
||||||
if (CurrentThread->Tcb.State == THREAD_STATE_TERMINATED_1)
|
case THREAD_STATE_TERMINATED_1:
|
||||||
{
|
PsQueueThreadReap(CurrentThread);
|
||||||
PiNrThreadsAwaitingReaping++;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Affinity = 1 << KeGetCurrentProcessorNumber();
|
Affinity = 1 << KeGetCurrentProcessorNumber();
|
||||||
|
@ -405,7 +399,7 @@ VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
|
||||||
if (Candidate == CurrentThread)
|
if (Candidate == CurrentThread)
|
||||||
{
|
{
|
||||||
Candidate->Tcb.State = THREAD_STATE_RUNNING;
|
Candidate->Tcb.State = THREAD_STATE_RUNNING;
|
||||||
KeReleaseSpinLockFromDpcLevel(&PiThreadListLock);
|
KeReleaseSpinLockFromDpcLevel(&PiThreadLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Candidate != NULL)
|
if (Candidate != NULL)
|
||||||
|
@ -418,17 +412,6 @@ VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
|
||||||
|
|
||||||
OldThread = CurrentThread;
|
OldThread = CurrentThread;
|
||||||
CurrentThread = Candidate;
|
CurrentThread = Candidate;
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* This code is moved to the end of KiArchContextSwitch.
|
|
||||||
* It should be execute after the context switch.
|
|
||||||
*/
|
|
||||||
KeReleaseSpinLockFromDpcLevel(&PiThreadListLock);
|
|
||||||
if (PiNrThreadsAwaitingReaping > 0)
|
|
||||||
{
|
|
||||||
PiWakeupReaperThread();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MmUpdatePageDir(PsGetCurrentProcess(),(PVOID)CurrentThread->ThreadsProcess, sizeof(EPROCESS));
|
MmUpdatePageDir(PsGetCurrentProcess(),(PVOID)CurrentThread->ThreadsProcess, sizeof(EPROCESS));
|
||||||
|
|
||||||
|
@ -450,7 +433,7 @@ PsDispatchThread(ULONG NewThreadStatus)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
/*
|
/*
|
||||||
* Save wait IRQL
|
* Save wait IRQL
|
||||||
*/
|
*/
|
||||||
|
@ -464,7 +447,7 @@ PsUnblockThread(PETHREAD Thread, PNTSTATUS WaitStatus)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
if (THREAD_STATE_TERMINATED_1 == Thread->Tcb.State ||
|
if (THREAD_STATE_TERMINATED_1 == Thread->Tcb.State ||
|
||||||
THREAD_STATE_TERMINATED_2 == Thread->Tcb.State)
|
THREAD_STATE_TERMINATED_2 == Thread->Tcb.State)
|
||||||
{
|
{
|
||||||
|
@ -486,7 +469,7 @@ PsUnblockThread(PETHREAD Thread, PNTSTATUS WaitStatus)
|
||||||
Thread->Tcb.State = THREAD_STATE_READY;
|
Thread->Tcb.State = THREAD_STATE_READY;
|
||||||
PsInsertIntoThreadList(Thread->Tcb.Priority, Thread);
|
PsInsertIntoThreadList(Thread->Tcb.Priority, Thread);
|
||||||
}
|
}
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
KeReleaseSpinLock(&PiThreadLock, oldIrql);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -498,7 +481,7 @@ PsBlockThread(PNTSTATUS Status, UCHAR Alertable, ULONG WaitMode,
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
PKWAIT_BLOCK WaitBlock;
|
PKWAIT_BLOCK WaitBlock;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
|
|
||||||
KThread = ((PIKPCR) KeGetCurrentKPCR())->CurrentThread;
|
KThread = ((PIKPCR) KeGetCurrentKPCR())->CurrentThread;
|
||||||
Thread = CONTAINING_RECORD (KThread, ETHREAD, Tcb);
|
Thread = CONTAINING_RECORD (KThread, ETHREAD, Tcb);
|
||||||
|
@ -553,13 +536,13 @@ PsFreezeAllThreads(PEPROCESS Process)
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
PETHREAD current;
|
PETHREAD current;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
|
|
||||||
current_entry = Process->ThreadListHead.Flink;
|
current_entry = Process->ThreadListHead.Flink;
|
||||||
while (current_entry != &Process->ThreadListHead)
|
while (current_entry != &Process->ThreadListHead)
|
||||||
{
|
{
|
||||||
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
||||||
Tcb.ProcessThreadListEntry);
|
ThreadListEntry);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have to be careful here, we can't just set the freeze the
|
* We have to be careful here, we can't just set the freeze the
|
||||||
|
@ -569,7 +552,7 @@ PsFreezeAllThreads(PEPROCESS Process)
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
KeReleaseSpinLock(&PiThreadLock, oldIrql);
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
|
@ -579,7 +562,7 @@ PsEnumThreadsByProcess(PEPROCESS Process)
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
ULONG Count = 0;
|
ULONG Count = 0;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
|
|
||||||
current_entry = Process->ThreadListHead.Flink;
|
current_entry = Process->ThreadListHead.Flink;
|
||||||
while (current_entry != &Process->ThreadListHead)
|
while (current_entry != &Process->ThreadListHead)
|
||||||
|
@ -588,7 +571,7 @@ PsEnumThreadsByProcess(PEPROCESS Process)
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
KeReleaseSpinLock(&PiThreadLock, oldIrql);
|
||||||
return Count;
|
return Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,7 +624,7 @@ PsSetThreadWin32Thread(
|
||||||
PVOID Win32Thread
|
PVOID Win32Thread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Thread->Win32Thread = Win32Thread;
|
Thread->Tcb.Win32Thread = Win32Thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -680,19 +663,18 @@ PsInitThreadManagment(VOID)
|
||||||
* FUNCTION: Initialize thread managment
|
* FUNCTION: Initialize thread managment
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
HANDLE PiReaperThreadHandle;
|
||||||
PETHREAD FirstThread;
|
PETHREAD FirstThread;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
HANDLE FirstThreadHandle;
|
HANDLE FirstThreadHandle;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
KeInitializeSpinLock(&PiThreadListLock);
|
KeInitializeSpinLock(&PiThreadLock);
|
||||||
for (i=0; i < MAXIMUM_PRIORITY; i++)
|
for (i=0; i < MAXIMUM_PRIORITY; i++)
|
||||||
{
|
{
|
||||||
InitializeListHead(&PriorityListHead[i]);
|
InitializeListHead(&PriorityListHead[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeListHead(&PiThreadListHead);
|
|
||||||
|
|
||||||
PsThreadType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
|
PsThreadType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
|
||||||
|
|
||||||
PsThreadType->Tag = TAG('T', 'H', 'R', 'T');
|
PsThreadType->Tag = TAG('T', 'H', 'R', 'T');
|
||||||
|
@ -732,6 +714,7 @@ PsInitThreadManagment(VOID)
|
||||||
/*
|
/*
|
||||||
* Create the reaper thread
|
* Create the reaper thread
|
||||||
*/
|
*/
|
||||||
|
PsInitializeThreadReaper();
|
||||||
KeInitializeEvent(&PiReaperThreadEvent, SynchronizationEvent, FALSE);
|
KeInitializeEvent(&PiReaperThreadEvent, SynchronizationEvent, FALSE);
|
||||||
Status = PsCreateSystemThread(&PiReaperThreadHandle,
|
Status = PsCreateSystemThread(&PiReaperThreadHandle,
|
||||||
THREAD_ALL_ACCESS,
|
THREAD_ALL_ACCESS,
|
||||||
|
@ -745,6 +728,8 @@ PsInitThreadManagment(VOID)
|
||||||
DPRINT1("PS: Failed to create reaper thread.\n");
|
DPRINT1("PS: Failed to create reaper thread.\n");
|
||||||
KEBUGCHECK(0);
|
KEBUGCHECK(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NtClose(PiReaperThreadHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -797,7 +782,7 @@ KeSetPriorityThread (PKTHREAD Thread, KPRIORITY Priority)
|
||||||
KEBUGCHECK(0);
|
KEBUGCHECK(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadLock, &oldIrql);
|
||||||
|
|
||||||
OldPriority = Thread->Priority;
|
OldPriority = Thread->Priority;
|
||||||
Thread->BasePriority = Thread->Priority = (CHAR)Priority;
|
Thread->BasePriority = Thread->Priority = (CHAR)Priority;
|
||||||
|
@ -831,7 +816,7 @@ KeSetPriorityThread (PKTHREAD Thread, KPRIORITY Priority)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
KeReleaseSpinLock(&PiThreadLock, oldIrql);
|
||||||
return(OldPriority);
|
return(OldPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,40 +952,26 @@ PsLookupProcessThreadByCid(IN PCLIENT_ID Cid,
|
||||||
OUT PEPROCESS *Process OPTIONAL,
|
OUT PEPROCESS *Process OPTIONAL,
|
||||||
OUT PETHREAD *Thread)
|
OUT PETHREAD *Thread)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
PCID_OBJECT CidObject;
|
||||||
PLIST_ENTRY current_entry;
|
PETHREAD FoundThread;
|
||||||
PETHREAD current;
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
CidObject = PsLockCidHandle((HANDLE)Cid->UniqueThread, PsThreadType);
|
||||||
|
if(CidObject != NULL)
|
||||||
|
{
|
||||||
|
FoundThread = CidObject->Obj.Thread;
|
||||||
|
ObReferenceObject(FoundThread);
|
||||||
|
|
||||||
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)
|
if(Process != NULL)
|
||||||
{
|
{
|
||||||
*Process = current->ThreadsProcess;
|
*Process = FoundThread->ThreadsProcess;
|
||||||
ObReferenceObject(current->ThreadsProcess);
|
ObReferenceObject(FoundThread->ThreadsProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
*Thread = current;
|
PsUnlockCidObject(CidObject);
|
||||||
ObReferenceObject(current);
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current_entry = current_entry->Flink;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
|
||||||
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
|
|
||||||
return(STATUS_INVALID_PARAMETER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1011,32 +982,19 @@ NTSTATUS STDCALL
|
||||||
PsLookupThreadByThreadId(IN PVOID ThreadId,
|
PsLookupThreadByThreadId(IN PVOID ThreadId,
|
||||||
OUT PETHREAD *Thread)
|
OUT PETHREAD *Thread)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
PCID_OBJECT CidObject;
|
||||||
PLIST_ENTRY current_entry;
|
|
||||||
PETHREAD current;
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
CidObject = PsLockCidHandle((HANDLE)ThreadId, PsThreadType);
|
||||||
|
if(CidObject != NULL)
|
||||||
|
{
|
||||||
|
*Thread = CidObject->Obj.Thread;
|
||||||
|
ObReferenceObject(*Thread);
|
||||||
|
|
||||||
current_entry = PiThreadListHead.Flink;
|
PsUnlockCidObject(CidObject);
|
||||||
while (current_entry != &PiThreadListHead)
|
return STATUS_SUCCESS;
|
||||||
{
|
|
||||||
current = CONTAINING_RECORD(current_entry,
|
|
||||||
ETHREAD,
|
|
||||||
Tcb.ThreadListEntry);
|
|
||||||
if (current->Cid.UniqueThread == (HANDLE)ThreadId)
|
|
||||||
{
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
*Thread = current;
|
|
||||||
ObReferenceObject(current);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current_entry = current_entry->Flink;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
|
||||||
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
|
|
||||||
return(STATUS_INVALID_PARAMETER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: tinfo.c,v 1.28 2004/08/15 16:39:10 chorns Exp $
|
/* $Id: tinfo.c,v 1.29 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -116,6 +116,7 @@ NtSetInformationThread (IN HANDLE ThreadHandle,
|
||||||
Status = STATUS_INVALID_INFO_CLASS;
|
Status = STATUS_INVALID_INFO_CLASS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef _ENABLE_THRDEVTPAIR
|
||||||
case ThreadEventPair:
|
case ThreadEventPair:
|
||||||
{
|
{
|
||||||
PKEVENT_PAIR EventPair;
|
PKEVENT_PAIR EventPair;
|
||||||
|
@ -149,6 +150,13 @@ NtSetInformationThread (IN HANDLE ThreadHandle,
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#else /* !_ENABLE_THRDEVTPAIR */
|
||||||
|
case ThreadEventPair:
|
||||||
|
{
|
||||||
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif /* _ENABLE_THRDEVTPAIR */
|
||||||
|
|
||||||
case ThreadQuerySetWin32StartAddress:
|
case ThreadQuerySetWin32StartAddress:
|
||||||
if (ThreadInformationLength != sizeof(ULONG))
|
if (ThreadInformationLength != sizeof(ULONG))
|
||||||
|
@ -156,7 +164,7 @@ NtSetInformationThread (IN HANDLE ThreadHandle,
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Thread->u2.Win32StartAddress = (PVOID)*((PULONG)ThreadInformation);
|
Thread->Win32StartAddress = (PVOID)*((PULONG)ThreadInformation);
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -270,7 +278,7 @@ NtQueryInformationThread (IN HANDLE ThreadHandle,
|
||||||
TTI->UserTime.QuadPart = Thread->Tcb.UserTime * 100000LL;
|
TTI->UserTime.QuadPart = Thread->Tcb.UserTime * 100000LL;
|
||||||
TTI->CreateTime = (TIME) Thread->CreateTime;
|
TTI->CreateTime = (TIME) Thread->CreateTime;
|
||||||
/*This works*/
|
/*This works*/
|
||||||
TTI->ExitTime = (TIME) Thread->u1.ExitTime;
|
TTI->ExitTime = (TIME) Thread->ExitTime;
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
@ -317,7 +325,7 @@ NtQueryInformationThread (IN HANDLE ThreadHandle,
|
||||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*((PVOID*)ThreadInformation) = Thread->u2.Win32StartAddress;
|
*((PVOID*)ThreadInformation) = Thread->Win32StartAddress;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: win32.c,v 1.8 2004/08/15 16:39:10 chorns Exp $
|
/* $Id: win32.c,v 1.9 2004/09/28 15:02:29 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -45,7 +45,7 @@ static ULONG PspWin32ThreadSize = 0;
|
||||||
PW32THREAD STDCALL
|
PW32THREAD STDCALL
|
||||||
PsGetWin32Thread(VOID)
|
PsGetWin32Thread(VOID)
|
||||||
{
|
{
|
||||||
return(PsGetCurrentThread()->Win32Thread);
|
return(PsGetCurrentThread()->Tcb.Win32Thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
PW32PROCESS STDCALL
|
PW32PROCESS STDCALL
|
||||||
|
@ -114,14 +114,14 @@ PsInitWin32Thread (PETHREAD Thread)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Thread->Win32Thread == NULL)
|
if (Thread->Tcb.Win32Thread == NULL)
|
||||||
{
|
{
|
||||||
Thread->Win32Thread = ExAllocatePool (NonPagedPool,
|
Thread->Tcb.Win32Thread = ExAllocatePool (NonPagedPool,
|
||||||
PspWin32ThreadSize);
|
PspWin32ThreadSize);
|
||||||
if (Thread->Win32Thread == NULL)
|
if (Thread->Tcb.Win32Thread == NULL)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
RtlZeroMemory (Thread->Win32Thread,
|
RtlZeroMemory (Thread->Tcb.Win32Thread,
|
||||||
PspWin32ThreadSize);
|
PspWin32ThreadSize);
|
||||||
|
|
||||||
if (PspWin32ThreadCallback != NULL)
|
if (PspWin32ThreadCallback != NULL)
|
||||||
|
@ -152,15 +152,15 @@ PsTerminateWin32Process (PEPROCESS Process)
|
||||||
VOID
|
VOID
|
||||||
PsTerminateWin32Thread (PETHREAD Thread)
|
PsTerminateWin32Thread (PETHREAD Thread)
|
||||||
{
|
{
|
||||||
if (Thread->Win32Thread == NULL)
|
if (Thread->Tcb.Win32Thread != NULL)
|
||||||
return;
|
{
|
||||||
|
|
||||||
if (PspWin32ThreadCallback != NULL)
|
if (PspWin32ThreadCallback != NULL)
|
||||||
{
|
{
|
||||||
PspWin32ThreadCallback (Thread, FALSE);
|
PspWin32ThreadCallback (Thread, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExFreePool (Thread->Win32Thread);
|
ExFreePool (Thread->Tcb.Win32Thread);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -138,8 +138,8 @@ typedef struct _WINDOW_OBJECT
|
||||||
ObmDereferenceObject(WndObj)
|
ObmDereferenceObject(WndObj)
|
||||||
|
|
||||||
#define IntWndBelongsToThread(WndObj, W32Thread) \
|
#define IntWndBelongsToThread(WndObj, W32Thread) \
|
||||||
(((WndObj->OwnerThread && WndObj->OwnerThread->Win32Thread)) && \
|
(((WndObj->OwnerThread && WndObj->OwnerThread->Tcb.Win32Thread)) && \
|
||||||
(WndObj->OwnerThread->Win32Thread == W32Thread))
|
(WndObj->OwnerThread->Tcb.Win32Thread == W32Thread))
|
||||||
|
|
||||||
#define IntGetWndThreadId(WndObj) \
|
#define IntGetWndThreadId(WndObj) \
|
||||||
WndObj->OwnerThread->Cid.UniqueThread
|
WndObj->OwnerThread->Cid.UniqueThread
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: dllmain.c,v 1.79 2004/08/08 17:57:34 weiden Exp $
|
/* $Id: dllmain.c,v 1.80 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* Entry Point for win32k.sys
|
* Entry Point for win32k.sys
|
||||||
*/
|
*/
|
||||||
|
@ -135,7 +135,7 @@ Win32kThreadCallback (struct _ETHREAD *Thread,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Process = Thread->ThreadsProcess;
|
Process = Thread->ThreadsProcess;
|
||||||
Win32Thread = Thread->Win32Thread;
|
Win32Thread = Thread->Tcb.Win32Thread;
|
||||||
if (Create)
|
if (Create)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*
|
*
|
||||||
* $Id: desktop.c,v 1.21 2004/09/15 20:53:43 mf Exp $
|
* $Id: desktop.c,v 1.22 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -954,14 +954,14 @@ NtUserGetThreadDesktop(DWORD dwThreadId, DWORD Unknown1)
|
||||||
{
|
{
|
||||||
/* just return the handle, we queried the desktop handle of a thread running
|
/* just return the handle, we queried the desktop handle of a thread running
|
||||||
in the same context */
|
in the same context */
|
||||||
Ret = Thread->Win32Thread->hDesktop;
|
Ret = Thread->Tcb.Win32Thread->hDesktop;
|
||||||
ObDereferenceObject(Thread);
|
ObDereferenceObject(Thread);
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the desktop handle and the desktop of the thread */
|
/* get the desktop handle and the desktop of the thread */
|
||||||
if(!(hThreadDesktop = Thread->Win32Thread->hDesktop) ||
|
if(!(hThreadDesktop = Thread->Tcb.Win32Thread->hDesktop) ||
|
||||||
!(DesktopObject = Thread->Win32Thread->Desktop))
|
!(DesktopObject = Thread->Tcb.Win32Thread->Desktop))
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Thread);
|
ObDereferenceObject(Thread);
|
||||||
DPRINT1("Desktop information of thread 0x%x broken!?\n", dwThreadId);
|
DPRINT1("Desktop information of thread 0x%x broken!?\n", dwThreadId);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: hook.c,v 1.8 2004/05/10 17:07:18 weiden Exp $
|
/* $Id: hook.c,v 1.9 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -64,7 +64,7 @@ STATIC FASTCALL PHOOK
|
||||||
IntAddHook(PETHREAD Thread, int HookId, BOOLEAN Global, PWINSTATION_OBJECT WinStaObj)
|
IntAddHook(PETHREAD Thread, int HookId, BOOLEAN Global, PWINSTATION_OBJECT WinStaObj)
|
||||||
{
|
{
|
||||||
PHOOK Hook;
|
PHOOK Hook;
|
||||||
PHOOKTABLE Table = Global ? GlobalHooks : MsqGetHooks(Thread->Win32Thread->MessageQueue);
|
PHOOKTABLE Table = Global ? GlobalHooks : MsqGetHooks(Thread->Tcb.Win32Thread->MessageQueue);
|
||||||
HANDLE Handle;
|
HANDLE Handle;
|
||||||
|
|
||||||
if (NULL == Table)
|
if (NULL == Table)
|
||||||
|
@ -80,7 +80,7 @@ IntAddHook(PETHREAD Thread, int HookId, BOOLEAN Global, PWINSTATION_OBJECT WinSt
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MsqSetHooks(Thread->Win32Thread->MessageQueue, Table);
|
MsqSetHooks(Thread->Tcb.Win32Thread->MessageQueue, Table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ IntGetTable(PHOOK Hook)
|
||||||
return GlobalHooks;
|
return GlobalHooks;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MsqGetHooks(Hook->Thread->Win32Thread->MessageQueue);
|
return MsqGetHooks(Hook->Thread->Tcb.Win32Thread->MessageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the first hook in the chain */
|
/* get the first hook in the chain */
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: input.c,v 1.37 2004/07/30 09:42:11 weiden Exp $
|
/* $Id: input.c,v 1.38 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -371,11 +371,11 @@ KeyboardThreadMain(PVOID StartContext)
|
||||||
|
|
||||||
FocusThread = FocusQueue->Thread;
|
FocusThread = FocusQueue->Thread;
|
||||||
|
|
||||||
if (FocusThread && FocusThread->Win32Thread &&
|
if (FocusThread && FocusThread->Tcb.Win32Thread &&
|
||||||
FocusThread->Win32Thread->KeyboardLayout)
|
FocusThread->Tcb.Win32Thread->KeyboardLayout)
|
||||||
{
|
{
|
||||||
W32kKeyProcessMessage(&msg,
|
W32kKeyProcessMessage(&msg,
|
||||||
FocusThread->Win32Thread->KeyboardLayout);
|
FocusThread->Tcb.Win32Thread->KeyboardLayout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: message.c,v 1.73 2004/09/12 19:29:22 gvg Exp $
|
/* $Id: message.c,v 1.74 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -1154,7 +1154,7 @@ NtUserPostThreadMessage(DWORD idThread,
|
||||||
Status = PsLookupThreadByThreadId((void *)idThread,&peThread);
|
Status = PsLookupThreadByThreadId((void *)idThread,&peThread);
|
||||||
|
|
||||||
if( Status == STATUS_SUCCESS ) {
|
if( Status == STATUS_SUCCESS ) {
|
||||||
pThread = peThread->Win32Thread;
|
pThread = peThread->Tcb.Win32Thread;
|
||||||
if( !pThread || !pThread->MessageQueue )
|
if( !pThread || !pThread->MessageQueue )
|
||||||
{
|
{
|
||||||
ObDereferenceObject( peThread );
|
ObDereferenceObject( peThread );
|
||||||
|
@ -1606,18 +1606,18 @@ NtUserGetQueueStatus(BOOL ClearChanges)
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
IntInitMessagePumpHook()
|
IntInitMessagePumpHook()
|
||||||
{
|
{
|
||||||
PsGetCurrentThread()->Win32Thread->MessagePumpHookValue++;
|
PsGetCurrentThread()->Tcb.Win32Thread->MessagePumpHookValue++;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
IntUninitMessagePumpHook()
|
IntUninitMessagePumpHook()
|
||||||
{
|
{
|
||||||
if (PsGetCurrentThread()->Win32Thread->MessagePumpHookValue <= 0)
|
if (PsGetCurrentThread()->Tcb.Win32Thread->MessagePumpHookValue <= 0)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
PsGetCurrentThread()->Win32Thread->MessagePumpHookValue--;
|
PsGetCurrentThread()->Tcb.Win32Thread->MessagePumpHookValue--;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: misc.c,v 1.85 2004/09/13 21:37:32 weiden Exp $
|
/* $Id: misc.c,v 1.86 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -108,7 +108,7 @@ NtUserCallNoParam(DWORD Routine)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NOPARAM_ROUTINE_DESTROY_CARET:
|
case NOPARAM_ROUTINE_DESTROY_CARET:
|
||||||
Result = (DWORD)IntDestroyCaret(PsGetCurrentThread()->Win32Thread);
|
Result = (DWORD)IntDestroyCaret(PsGetCurrentThread()->Tcb.Win32Thread);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NOPARAM_ROUTINE_INIT_MESSAGE_PUMP:
|
case NOPARAM_ROUTINE_INIT_MESSAGE_PUMP:
|
||||||
|
@ -422,7 +422,7 @@ NtUserCallTwoParam(
|
||||||
|
|
||||||
case TWOPARAM_ROUTINE_SETGUITHRDHANDLE:
|
case TWOPARAM_ROUTINE_SETGUITHRDHANDLE:
|
||||||
{
|
{
|
||||||
PUSER_MESSAGE_QUEUE MsgQueue = PsGetCurrentThread()->Win32Thread->MessageQueue;
|
PUSER_MESSAGE_QUEUE MsgQueue = PsGetCurrentThread()->Tcb.Win32Thread->MessageQueue;
|
||||||
|
|
||||||
ASSERT(MsgQueue);
|
ASSERT(MsgQueue);
|
||||||
return (DWORD)MsqSetStateWindow(MsgQueue, (ULONG)Param1, (HWND)Param2);
|
return (DWORD)MsqSetStateWindow(MsgQueue, (ULONG)Param1, (HWND)Param2);
|
||||||
|
@ -1087,12 +1087,12 @@ NtUserGetGUIThreadInfo(
|
||||||
SetLastWin32Error(ERROR_ACCESS_DENIED);
|
SetLastWin32Error(ERROR_ACCESS_DENIED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
Desktop = Thread->Win32Thread->Desktop;
|
Desktop = Thread->Tcb.Win32Thread->Desktop;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* get the foreground thread */
|
/* get the foreground thread */
|
||||||
PW32THREAD W32Thread = PsGetCurrentThread()->Win32Thread;
|
PW32THREAD W32Thread = PsGetCurrentThread()->Tcb.Win32Thread;
|
||||||
Desktop = W32Thread->Desktop;
|
Desktop = W32Thread->Desktop;
|
||||||
if(Desktop)
|
if(Desktop)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: msgqueue.c,v 1.106 2004/09/12 19:29:23 gvg Exp $
|
/* $Id: msgqueue.c,v 1.107 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -627,7 +627,7 @@ MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Win32Thread = ((PETHREAD)Thread)->Win32Thread;
|
Win32Thread = ((PETHREAD)Thread)->Tcb.Win32Thread;
|
||||||
if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
|
if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
|
||||||
{
|
{
|
||||||
ObDereferenceObject ((PETHREAD)Thread);
|
ObDereferenceObject ((PETHREAD)Thread);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*
|
*
|
||||||
* $Id: painting.c,v 1.85 2004/09/24 15:07:38 navaraf Exp $
|
* $Id: painting.c,v 1.86 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -676,7 +676,7 @@ IntFixCaret(HWND hWnd, LPRECT lprc, UINT flags)
|
||||||
PTHRDCARETINFO CaretInfo;
|
PTHRDCARETINFO CaretInfo;
|
||||||
HWND hWndCaret;
|
HWND hWndCaret;
|
||||||
|
|
||||||
Desktop = PsGetCurrentThread()->Win32Thread->Desktop;
|
Desktop = PsGetCurrentThread()->Tcb.Win32Thread->Desktop;
|
||||||
CaretInfo = ((PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue)->CaretInfo;
|
CaretInfo = ((PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue)->CaretInfo;
|
||||||
hWndCaret = CaretInfo->hWnd;
|
hWndCaret = CaretInfo->hWnd;
|
||||||
if (hWndCaret == hWnd ||
|
if (hWndCaret == hWnd ||
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: timer.c,v 1.35 2004/08/04 22:31:17 weiden Exp $
|
/* $Id: timer.c,v 1.36 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -405,7 +405,7 @@ TimerThreadMain(PVOID StartContext)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MsqPostMessage(((PW32THREAD)Thread->Win32Thread)->MessageQueue, &MsgTimer->Msg, FALSE);
|
MsqPostMessage(Thread->Tcb.Win32Thread->MessageQueue, &MsgTimer->Msg, FALSE);
|
||||||
|
|
||||||
ThreadsToDereference[ThreadsToDereferencePos] = Thread;
|
ThreadsToDereference[ThreadsToDereferencePos] = Thread;
|
||||||
++ThreadsToDereferencePos;
|
++ThreadsToDereferencePos;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: window.c,v 1.246 2004/07/26 14:58:35 jimtabor Exp $
|
/* $Id: window.c,v 1.247 2004/09/28 15:02:30 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -267,10 +267,10 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window,
|
||||||
|
|
||||||
RemoveTimersWindow(Window->Self);
|
RemoveTimersWindow(Window->Self);
|
||||||
|
|
||||||
IntLockThreadWindows(Window->OwnerThread->Win32Thread);
|
IntLockThreadWindows(Window->OwnerThread->Tcb.Win32Thread);
|
||||||
if(Window->Status & WINDOWSTATUS_DESTROYING)
|
if(Window->Status & WINDOWSTATUS_DESTROYING)
|
||||||
{
|
{
|
||||||
IntUnLockThreadWindows(Window->OwnerThread->Win32Thread);
|
IntUnLockThreadWindows(Window->OwnerThread->Tcb.Win32Thread);
|
||||||
DPRINT("Tried to call IntDestroyWindow() twice\n");
|
DPRINT("Tried to call IntDestroyWindow() twice\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window,
|
||||||
don't get into trouble when destroying the thread windows while we're still
|
don't get into trouble when destroying the thread windows while we're still
|
||||||
in IntDestroyWindow() */
|
in IntDestroyWindow() */
|
||||||
RemoveEntryList(&Window->ThreadListEntry);
|
RemoveEntryList(&Window->ThreadListEntry);
|
||||||
IntUnLockThreadWindows(Window->OwnerThread->Win32Thread);
|
IntUnLockThreadWindows(Window->OwnerThread->Tcb.Win32Thread);
|
||||||
|
|
||||||
BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
|
BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
|
||||||
|
|
||||||
|
@ -382,10 +382,10 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window,
|
||||||
|
|
||||||
IntDestroyScrollBars(Window);
|
IntDestroyScrollBars(Window);
|
||||||
|
|
||||||
IntLockThreadWindows(Window->OwnerThread->Win32Thread);
|
IntLockThreadWindows(Window->OwnerThread->Tcb.Win32Thread);
|
||||||
Window->Status |= WINDOWSTATUS_DESTROYED;
|
Window->Status |= WINDOWSTATUS_DESTROYED;
|
||||||
/* don't remove the WINDOWSTATUS_DESTROYING bit */
|
/* don't remove the WINDOWSTATUS_DESTROYING bit */
|
||||||
IntUnLockThreadWindows(Window->OwnerThread->Win32Thread);
|
IntUnLockThreadWindows(Window->OwnerThread->Tcb.Win32Thread);
|
||||||
|
|
||||||
/* remove the window from the class object */
|
/* remove the window from the class object */
|
||||||
IntLockClassWindows(Window->Class);
|
IntLockClassWindows(Window->Class);
|
||||||
|
@ -527,7 +527,7 @@ DestroyThreadWindows(struct _ETHREAD *Thread)
|
||||||
PWINDOW_OBJECT *List, *pWnd;
|
PWINDOW_OBJECT *List, *pWnd;
|
||||||
ULONG Cnt = 0;
|
ULONG Cnt = 0;
|
||||||
|
|
||||||
Win32Thread = Thread->Win32Thread;
|
Win32Thread = Thread->Tcb.Win32Thread;
|
||||||
Win32Process = Thread->ThreadsProcess->Win32Process;
|
Win32Process = Thread->ThreadsProcess->Win32Process;
|
||||||
|
|
||||||
IntLockThreadWindows(Win32Thread);
|
IntLockThreadWindows(Win32Thread);
|
||||||
|
@ -1166,7 +1166,7 @@ NtUserBuildHwndList(
|
||||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(!(W32Thread = Thread->Win32Thread))
|
if(!(W32Thread = Thread->Tcb.Win32Thread))
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Thread);
|
ObDereferenceObject(Thread);
|
||||||
DPRINT1("Thread is not a GUI Thread!\n");
|
DPRINT1("Thread is not a GUI Thread!\n");
|
||||||
|
@ -1718,7 +1718,7 @@ IntCreateWindowEx(DWORD dwExStyle,
|
||||||
PRTL_USER_PROCESS_PARAMETERS ProcessParams;
|
PRTL_USER_PROCESS_PARAMETERS ProcessParams;
|
||||||
BOOL CalculatedDefPosSize = FALSE;
|
BOOL CalculatedDefPosSize = FALSE;
|
||||||
|
|
||||||
IntGetDesktopWorkArea(WindowObject->OwnerThread->Win32Thread->Desktop, &WorkArea);
|
IntGetDesktopWorkArea(WindowObject->OwnerThread->Tcb.Win32Thread->Desktop, &WorkArea);
|
||||||
|
|
||||||
rc = WorkArea;
|
rc = WorkArea;
|
||||||
ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
|
ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
#include <internal/safe.h>
|
#include <internal/safe.h>
|
||||||
|
#include <internal/ps.h>
|
||||||
|
|
||||||
#include <napi/win32.h>
|
#include <napi/win32.h>
|
||||||
#include <ntos.h>
|
#include <ntos.h>
|
||||||
|
|
Loading…
Reference in a new issue