Enable automatic initialization and termination of Win32 threads and processes.

svn path=/trunk/; revision=4933
This commit is contained in:
Eric Kohl 2003-06-20 16:26:53 +00:00
parent 76d1058fc3
commit ea01cf3f1f
26 changed files with 331 additions and 279 deletions

View file

@ -59,7 +59,6 @@ W32kDeleteDC 1
W32kDeleteEnhMetaFile 1 W32kDeleteEnhMetaFile 1
W32kDeleteMetaFile 1 W32kDeleteMetaFile 1
W32kDeleteObject 1 W32kDeleteObject 1
W32kCleanupForProcess 1
W32kDescribePixelFormat 4 W32kDescribePixelFormat 4
#W32kDeviceCapabilitiesEx ? #W32kDeviceCapabilitiesEx ?
W32kDrawEscape 4 W32kDrawEscape 4

View file

@ -1,4 +1,4 @@
/* $Id: psfuncs.h,v 1.23 2003/04/10 23:14:46 hyperion Exp $ /* $Id: psfuncs.h,v 1.24 2003/06/20 16:19:33 ekohl Exp $
*/ */
#ifndef _INCLUDE_DDK_PSFUNCS_H #ifndef _INCLUDE_DDK_PSFUNCS_H
#define _INCLUDE_DDK_PSFUNCS_H #define _INCLUDE_DDK_PSFUNCS_H
@ -41,8 +41,9 @@ NTSTATUS STDCALL PsCreateSystemProcess(PHANDLE ProcessHandle,
NTSTATUS STDCALL PsCreateWin32Process(struct _EPROCESS* Process); NTSTATUS STDCALL PsCreateWin32Process(struct _EPROCESS* Process);
NTSTATUS STDCALL PsCreateWin32Thread(struct _ETHREAD* Thread); NTSTATUS STDCALL PsCreateWin32Thread(struct _ETHREAD* Thread);
VOID STDCALL PsEstablishWin32Callouts(PVOID Param1, VOID STDCALL
PVOID Param2, PsEstablishWin32Callouts (PW32_PROCESS_CALLBACK W32ProcessCallback,
PW32_THREAD_CALLBACK W32ThreadCallback,
PVOID Param3, PVOID Param3,
PVOID Param4, PVOID Param4,
ULONG W32ThreadSize, ULONG W32ThreadSize,

View file

@ -23,16 +23,27 @@ struct _KTHREAD;
typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD; typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
typedef NTSTATUS STDCALL_FUNC (*PKSTART_ROUTINE)(PVOID StartContext); typedef NTSTATUS STDCALL_FUNC
(*PKSTART_ROUTINE)(PVOID StartContext);
typedef VOID STDCALL_FUNC (*PCREATE_PROCESS_NOTIFY_ROUTINE)(HANDLE ParentId, typedef VOID STDCALL_FUNC
(*PCREATE_PROCESS_NOTIFY_ROUTINE)(HANDLE ParentId,
HANDLE ProcessId, HANDLE ProcessId,
BOOLEAN Create); BOOLEAN Create);
typedef VOID STDCALL_FUNC (*PCREATE_THREAD_NOTIFY_ROUTINE)(HANDLE ProcessId, typedef VOID STDCALL_FUNC
(*PCREATE_THREAD_NOTIFY_ROUTINE)(HANDLE ProcessId,
HANDLE ThreadId, HANDLE ThreadId,
BOOLEAN Create); BOOLEAN Create);
typedef NTSTATUS STDCALL_FUNC
(*PW32_PROCESS_CALLBACK)(struct _EPROCESS *Process,
BOOLEAN Create);
typedef NTSTATUS STDCALL_FUNC
(*PW32_THREAD_CALLBACK)(struct _ETHREAD *Thread,
BOOLEAN Create);
typedef struct _STACK_INFORMATION typedef struct _STACK_INFORMATION
{ {
PVOID BaseAddress; PVOID BaseAddress;

View file

@ -100,8 +100,7 @@ BOOL FASTCALL GDIOBJ_LockMultipleObj( PGDIMULTILOCK pList, INT nObj );
BOOL FASTCALL GDIOBJ_UnlockObj (HGDIOBJ Obj, WORD Magic); BOOL FASTCALL GDIOBJ_UnlockObj (HGDIOBJ Obj, WORD Magic);
BOOL FASTCALL GDIOBJ_UnlockMultipleObj( PGDIMULTILOCK pList, INT nObj ); BOOL FASTCALL GDIOBJ_UnlockMultipleObj( PGDIMULTILOCK pList, INT nObj );
WORD FASTCALL GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle); WORD FASTCALL GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle);
VOID STDCALL W32kDumpGdiObjects( INT Process ); VOID STDCALL W32kDumpGdiObjects( INT Pid );
BOOL STDCALL W32kCleanupForProcess( INT Process );
#define GDIOBJFLAG_DEFAULT (0x0) #define GDIOBJFLAG_DEFAULT (0x0)
#define GDIOBJFLAG_IGNOREPID (0x1) #define GDIOBJFLAG_IGNOREPID (0x1)

View file

@ -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.47 2003/06/16 16:45:03 ekohl Exp $ /* $Id: ps.h,v 1.48 2003/06/20 16:20:34 ekohl Exp $
* *
* FILE: ntoskrnl/ke/kthread.c * FILE: ntoskrnl/ke/kthread.c
* PURPOSE: Process manager definitions * PURPOSE: Process manager definitions
@ -522,6 +522,16 @@ PsInitialiseSuspendImplementation(VOID);
extern ULONG PiNrThreadsAwaitingReaping; extern ULONG PiNrThreadsAwaitingReaping;
NTSTATUS
PsInitWin32Thread (PETHREAD Thread);
VOID
PsTerminateWin32Process (PEPROCESS Process);
VOID
PsTerminateWin32Thread (PETHREAD Thread);
#endif /* ASSEMBLER */ #endif /* ASSEMBLER */
#endif /* __INCLUDE_INTERNAL_PS_H */ #endif /* __INCLUDE_INTERNAL_PS_H */

View file

@ -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: syscall.S,v 1.11 2003/06/04 18:11:16 hbirr Exp $ /* $Id: syscall.S,v 1.12 2003/06/20 16:21:11 ekohl Exp $
* *
* FILE: ntoskrnl/hal/x86/syscall.s * FILE: ntoskrnl/hal/x86/syscall.s
* PURPOSE: 2E trap handler * PURPOSE: 2E trap handler
@ -198,8 +198,13 @@ new_shadowServiceInRange:
movw %bx,%ds movw %bx,%ds
/* Call system call hook */ /* Call system call hook */
// pushl %eax
// call _KiSystemCallHook
// popl %eax
/* Call service check routine */
pushl %eax pushl %eax
call _KiSystemCallHook call _KiServiceCheck
popl %eax popl %eax
/* Make the system service call */ /* Make the system service call */

View file

@ -1,4 +1,4 @@
/* $Id: usercall.c,v 1.23 2003/06/07 10:14:40 chorns Exp $ /* $Id: usercall.c,v 1.24 2003/06/20 16:21:11 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -59,6 +59,30 @@ ULONG KiAfterSystemCallHook(ULONG NtStatus, PKTRAP_FRAME TrapFrame)
return(NtStatus); return(NtStatus);
} }
VOID KiServiceCheck (ULONG Nr)
{
PETHREAD Thread;
Thread = PsGetCurrentThread();
#if 0
DbgPrint ("KiServiceCheck(%p) called\n", Thread);
DbgPrint ("Service %d (%p)\n", Nr, KeServiceDescriptorTableShadow[1].SSDT[Nr].SysCallPtr);
#endif
if (Thread->Tcb.ServiceTable != KeServiceDescriptorTableShadow)
{
#if 0
DbgPrint ("Initialize Win32 thread\n");
#endif
PsInitWin32Thread (Thread);
Thread->Tcb.ServiceTable = KeServiceDescriptorTableShadow;
}
}
// This function should be used by win32k.sys to add its own user32/gdi32 services // This function should be used by win32k.sys to add its own user32/gdi32 services
// TableIndex is 0 based // TableIndex is 0 based
// ServiceCountTable its not used at the moment // ServiceCountTable its not used at the moment

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.156 2003/06/11 12:29:49 ekohl Exp $ ; $Id: ntoskrnl.def,v 1.157 2003/06/20 16:22:56 ekohl Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -631,15 +631,14 @@ PsAssignImpersonationToken@8
;PsChargePoolQuota@12 ;PsChargePoolQuota@12
PsCreateSystemProcess@12 PsCreateSystemProcess@12
PsCreateSystemThread@28 PsCreateSystemThread@28
PsCreateWin32Thread@4
PsCreateWin32Process@4 PsCreateWin32Process@4
PsGetWin32Thread@0
PsGetWin32Process@0
PsEstablishWin32Callouts@24 PsEstablishWin32Callouts@24
PsGetCurrentProcessId@0 PsGetCurrentProcessId@0
PsGetCurrentThreadId@0 PsGetCurrentThreadId@0
PsGetProcessExitTime@0 PsGetProcessExitTime@0
PsGetVersion@16 PsGetVersion@16
PsGetWin32Thread@0
PsGetWin32Process@0
PsImpersonateClient@20 PsImpersonateClient@20
PsInitialSystemProcess DATA PsInitialSystemProcess DATA
PsIsThreadTerminating@4 PsIsThreadTerminating@4

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.142 2003/06/11 12:29:49 ekohl Exp $ ; $Id: ntoskrnl.edf,v 1.143 2003/06/20 16:22:56 ekohl Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -630,15 +630,14 @@ PsAssignImpersonationToken=PsAssignImpersonationToken@8
;PsChargePoolQuota=PsChargePoolQuota@12 ;PsChargePoolQuota=PsChargePoolQuota@12
PsCreateSystemProcess=PsCreateSystemProcess@12 PsCreateSystemProcess=PsCreateSystemProcess@12
PsCreateSystemThread=PsCreateSystemThread@28 PsCreateSystemThread=PsCreateSystemThread@28
PsCreateWin32Thread=PsCreateWin32Thread@4
PsCreateWin32Process=PsCreateWin32Process@4 PsCreateWin32Process=PsCreateWin32Process@4
PsGetWin32Thread=PsGetWin32Thread@0
PsGetWin32Process=PsGetWin32Process@0
PsEstablishWin32Callouts=PsEstablishWin32Callouts@24 PsEstablishWin32Callouts=PsEstablishWin32Callouts@24
PsGetCurrentProcessId=PsGetCurrentProcessId@0 PsGetCurrentProcessId=PsGetCurrentProcessId@0
PsGetCurrentThreadId=PsGetCurrentThreadId@0 PsGetCurrentThreadId=PsGetCurrentThreadId@0
PsGetProcessExitTime=PsGetProcessExitTime@0 PsGetProcessExitTime=PsGetProcessExitTime@0
PsGetVersion=PsGetVersion@16 PsGetVersion=PsGetVersion@16
PsGetWin32Thread=PsGetWin32Thread@0
PsGetWin32Process=PsGetWin32Process@0
PsImpersonateClient=PsImpersonateClient@20 PsImpersonateClient=PsImpersonateClient@20
PsInitialSystemProcess DATA PsInitialSystemProcess DATA
PsIsThreadTerminating=PsIsThreadTerminating@4 PsIsThreadTerminating=PsIsThreadTerminating@4

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.61 2003/06/07 12:23:14 chorns Exp $ /* $Id: create.c,v 1.62 2003/06/20 16:22:20 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -286,6 +286,9 @@ PiDeleteThread(PVOID ObjectBody)
DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody); DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
/* Terminate Win32 thread */
PsTerminateWin32Thread (Thread);
ObDereferenceObject(Thread->ThreadsProcess); ObDereferenceObject(Thread->ThreadsProcess);
Thread->ThreadsProcess = NULL; Thread->ThreadsProcess = NULL;

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.107 2003/06/07 12:23:14 chorns Exp $ /* $Id: process.c,v 1.108 2003/06/20 16:22:20 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -292,6 +292,10 @@ PiDeleteProcess(PVOID ObjectBody)
DPRINT("PiDeleteProcess(ObjectBody %x)\n",ObjectBody); DPRINT("PiDeleteProcess(ObjectBody %x)\n",ObjectBody);
Process = (PEPROCESS)ObjectBody; Process = (PEPROCESS)ObjectBody;
/* Terminate Win32 Process */
PsTerminateWin32Process (Process);
KeAcquireSpinLock(&PsProcessListLock, &oldIrql); KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
NotifyRoutineCount = 0; NotifyRoutineCount = 0;
for (i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; i++) for (i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; i++)
@ -306,7 +310,7 @@ PiDeleteProcess(PVOID ObjectBody)
for (i = 0;i < NotifyRoutineCount; i++) for (i = 0;i < NotifyRoutineCount; i++)
{ {
//must be called below DISPATCH_LVL /* must be called below DISPATCH_LVL */
NotifyRoutine[i](Process->InheritedFromUniqueProcessId, NotifyRoutine[i](Process->InheritedFromUniqueProcessId,
(HANDLE)Process->UniqueProcessId, (HANDLE)Process->UniqueProcessId,
FALSE); FALSE);

View file

@ -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.5 2002/09/08 10:23:41 chorns Exp $ /* $Id: win32.c,v 1.6 2003/06/20 16:22:20 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -37,6 +37,8 @@
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
static PW32_PROCESS_CALLBACK PspWin32ProcessCallback = NULL;
static PW32_THREAD_CALLBACK PspWin32ThreadCallback = NULL;
static ULONG PspWin32ProcessSize = 0; static ULONG PspWin32ProcessSize = 0;
static ULONG PspWin32ThreadSize = 0; static ULONG PspWin32ThreadSize = 0;
@ -48,23 +50,6 @@ PsGetWin32Thread(VOID)
return(PsGetCurrentThread()->Win32Thread); return(PsGetCurrentThread()->Win32Thread);
} }
NTSTATUS STDCALL
PsCreateWin32Thread(PETHREAD Thread)
{
if (Thread->Win32Thread != NULL)
return(STATUS_SUCCESS);
Thread->Win32Thread = ExAllocatePool(NonPagedPool,
PspWin32ThreadSize);
if (Thread->Win32Thread == NULL)
return(STATUS_NO_MEMORY);
RtlZeroMemory(Thread->Win32Thread,
PspWin32ThreadSize);
return(STATUS_SUCCESS);
}
PW32PROCESS STDCALL PW32PROCESS STDCALL
PsGetWin32Process(VOID) PsGetWin32Process(VOID)
{ {
@ -90,15 +75,91 @@ PsCreateWin32Process(PEPROCESS Process)
VOID STDCALL VOID STDCALL
PsEstablishWin32Callouts(PVOID Param1, PsEstablishWin32Callouts (PW32_PROCESS_CALLBACK W32ProcessCallback,
PVOID Param2, PW32_THREAD_CALLBACK W32ThreadCallback,
PVOID Param3, PVOID Param3,
PVOID Param4, PVOID Param4,
ULONG W32ThreadSize, ULONG W32ThreadSize,
ULONG W32ProcessSize) ULONG W32ProcessSize)
{ {
PspWin32ProcessCallback = W32ProcessCallback;
PspWin32ThreadCallback = W32ThreadCallback;
PspWin32ProcessSize = W32ProcessSize; PspWin32ProcessSize = W32ProcessSize;
PspWin32ThreadSize = W32ThreadSize; PspWin32ThreadSize = W32ThreadSize;
} }
NTSTATUS
PsInitWin32Thread (PETHREAD Thread)
{
PEPROCESS Process;
Process = Thread->ThreadsProcess;
if (Process->Win32Process == NULL)
{
Process->Win32Process = ExAllocatePool (NonPagedPool,
PspWin32ProcessSize);
if (Process->Win32Process == NULL)
return STATUS_NO_MEMORY;
RtlZeroMemory (Process->Win32Process,
PspWin32ProcessSize);
if (PspWin32ProcessCallback != NULL)
{
PspWin32ProcessCallback (Process, TRUE);
}
}
if (Thread->Win32Thread == NULL)
{
Thread->Win32Thread = ExAllocatePool (NonPagedPool,
PspWin32ThreadSize);
if (Thread->Win32Thread == NULL)
return STATUS_NO_MEMORY;
RtlZeroMemory (Thread->Win32Thread,
PspWin32ThreadSize);
if (PspWin32ThreadCallback != NULL)
{
PspWin32ThreadCallback (Thread, TRUE);
}
}
return(STATUS_SUCCESS);
}
VOID
PsTerminateWin32Process (PEPROCESS Process)
{
if (Process->Win32Process == NULL)
return;
if (PspWin32ProcessCallback != NULL)
{
PspWin32ProcessCallback (Process, FALSE);
}
ExFreePool (Process->Win32Process);
}
VOID
PsTerminateWin32Thread (PETHREAD Thread)
{
if (Thread->Win32Thread == NULL)
return;
if (PspWin32ThreadCallback != NULL)
{
PspWin32ThreadCallback (Thread, FALSE);
}
ExFreePool (Thread->Win32Thread);
}
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.26 2003/03/09 21:41:35 hbirr Exp $ /* $Id: process.c,v 1.27 2003/06/20 16:23:34 ekohl Exp $
* *
* reactos/subsys/csrss/api/process.c * reactos/subsys/csrss/api/process.c
* *
@ -18,8 +18,6 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
BOOL STDCALL W32kCleanupForProcess( INT Process );
#define LOCK RtlEnterCriticalSection(&ProcessDataLock) #define LOCK RtlEnterCriticalSection(&ProcessDataLock)
#define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock) #define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock)
@ -120,7 +118,6 @@ NTSTATUS STDCALL CsrFreeProcessData(ULONG Pid)
if (pProcessData) if (pProcessData)
{ {
//DbgPrint("CsrFreeProcessData pid: %d\n", Pid); //DbgPrint("CsrFreeProcessData pid: %d\n", Pid);
W32kCleanupForProcess(Pid); //should check if win32k process
if (pProcessData->HandleTable) if (pProcessData->HandleTable)
{ {
for( c = 0; c < pProcessData->HandleTableSize; c++ ) for( c = 0; c < pProcessData->HandleTableSize; c++ )

View file

@ -4,8 +4,6 @@
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
VOID FASTCALL
W32kGuiCheck(VOID);
VOID FASTCALL VOID FASTCALL
W32kGraphicsCheck(BOOL Create); W32kGraphicsCheck(BOOL Create);

View file

@ -116,6 +116,8 @@ VOID FASTCALL InitGdiObjectHandleTable (VOID);
VOID FASTCALL CreateStockObjects (VOID); VOID FASTCALL CreateStockObjects (VOID);
BOOL FASTCALL CleanupForProcess (struct _EPROCESS *Process, INT Pid);
VOID FASTCALL GDIOBJ_MarkObjectGlobal (HGDIOBJ ObjectHandle); VOID FASTCALL GDIOBJ_MarkObjectGlobal (HGDIOBJ ObjectHandle);
BOOL FASTCALL GDIOBJ_LockMultipleObj (PGDIMULTILOCK pList, INT nObj); BOOL FASTCALL GDIOBJ_LockMultipleObj (PGDIMULTILOCK pList, INT nObj);

View file

@ -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.38 2003/06/07 10:14:40 chorns Exp $ /* $Id: dllmain.c,v 1.39 2003/06/20 16:25:13 ekohl Exp $
* *
* Entry Point for win32k.sys * Entry Point for win32k.sys
*/ */
@ -37,7 +37,6 @@
#include <include/input.h> #include <include/input.h>
#include <include/timer.h> #include <include/timer.h>
#include <include/text.h> #include <include/text.h>
#include <include/cleanup.h>
#define NDEBUG #define NDEBUG
#include <win32k/debug1.h> #include <win32k/debug1.h>
@ -46,6 +45,113 @@ extern SSDT Win32kSSDT[];
extern SSPT Win32kSSPT[]; extern SSPT Win32kSSPT[];
extern ULONG Win32kNumberOfSysCalls; extern ULONG Win32kNumberOfSysCalls;
PEPROCESS W32kDeviceProcess;
NTSTATUS STDCALL
W32kProcessCallback (struct _EPROCESS *Process,
BOOLEAN Create)
{
PW32PROCESS Win32Process;
NTSTATUS Status;
#if 0
DbgPrint ("W32kProcessCallback() called\n");
#endif
Win32Process = Process->Win32Process;
if (Create)
{
#if 0
DbgPrint (" Create process\n");
#endif
InitializeListHead(&Win32Process->ClassListHead);
ExInitializeFastMutex(&Win32Process->ClassListLock);
Win32Process->WindowStation = NULL;
if (Process->Win32WindowStation != NULL)
{
Status =
ValidateWindowStationHandle(Process->Win32WindowStation,
UserMode,
GENERIC_ALL,
&Win32Process->WindowStation);
if (!NT_SUCCESS(Status))
{
DbgPrint("W32K: Failed to reference a window station for "
"process.\n");
}
}
}
else
{
#if 0
DbgPrint (" Destroy process\n");
DbgPrint (" IRQ level: %lu\n", KeGetCurrentIrql ());
#endif
CleanupForProcess(Process, Process->UniqueProcessId);
}
return STATUS_SUCCESS;
}
NTSTATUS STDCALL
W32kThreadCallback (struct _ETHREAD *Thread,
BOOLEAN Create)
{
struct _EPROCESS *Process;
PW32THREAD Win32Thread;
NTSTATUS Status;
#if 0
DbgPrint ("W32kThreadCallback() called\n");
#endif
Process = Thread->ThreadsProcess;
Win32Thread = Thread->Win32Thread;
if (Create)
{
#if 0
DbgPrint (" Create thread\n");
#endif
Win32Thread->MessageQueue = MsqCreateMessageQueue();
InitializeListHead(&Win32Thread->WindowListHead);
ExInitializeFastMutex(&Win32Thread->WindowListLock);
/* By default threads get assigned their process's desktop. */
Win32Thread->Desktop = NULL;
if (Process->Win32Desktop != NULL)
{
Status = ObReferenceObjectByHandle(Process->Win32Desktop,
GENERIC_ALL,
ExDesktopObjectType,
UserMode,
(PVOID*)&Win32Thread->Desktop,
NULL);
if (!NT_SUCCESS(Status))
{
DbgPrint("W32K: Failed to reference a desktop for thread.\n");
}
}
}
else
{
#if 0
DbgPrint (" Destroy thread\n");
#endif
RemoveTimersThread(Thread->Cid.UniqueThread);
}
return STATUS_SUCCESS;
}
/* /*
* This definition doesn't work * This definition doesn't work
*/ */
@ -63,8 +169,11 @@ DllMain (
* Register user mode call interface * Register user mode call interface
* (system service table index = 1) * (system service table index = 1)
*/ */
Result = KeAddSystemServiceTable (Win32kSSDT, NULL, Result = KeAddSystemServiceTable (Win32kSSDT,
Win32kNumberOfSysCalls, Win32kSSPT, 1); NULL,
Win32kNumberOfSysCalls,
Win32kSSPT,
1);
if (Result == FALSE) if (Result == FALSE)
{ {
DbgPrint("Adding system services failed!\n"); DbgPrint("Adding system services failed!\n");
@ -74,7 +183,12 @@ DllMain (
/* /*
* Register our per-process and per-thread structures. * Register our per-process and per-thread structures.
*/ */
PsEstablishWin32Callouts(0, 0, 0, 0, sizeof(W32THREAD), sizeof(W32PROCESS)); PsEstablishWin32Callouts (W32kProcessCallback,
W32kThreadCallback,
0,
0,
sizeof(W32THREAD),
sizeof(W32PROCESS));
WinPosSetupInternalPos(); WinPosSetupInternalPos();
@ -120,17 +234,9 @@ DllMain (
return(Status); return(Status);
} }
Status = InitCleanupImpl();
if (!NT_SUCCESS(Status))
{
DbgPrint("Failed to initialize cleanup implementation.\n");
return(Status);
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
PEPROCESS W32kDeviceProcess;
BOOLEAN BOOLEAN
STDCALL STDCALL

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.66 2003/06/19 17:13:28 gvg Exp $ # $Id: makefile,v 1.67 2003/06/20 16:24:06 ekohl Exp $
PATH_TO_TOP = ../.. PATH_TO_TOP = ../..
@ -50,7 +50,7 @@ NTUSER_OBJECTS = ntuser/class.o ntuser/guicheck.o ntuser/hook.o \
ntuser/input.o ntuser/keyboard.o ntuser/callback.o \ ntuser/input.o ntuser/keyboard.o ntuser/callback.o \
ntuser/winpos.o ntuser/painting.o ntuser/metric.o \ ntuser/winpos.o ntuser/painting.o ntuser/metric.o \
ntuser/windc.o ntuser/prop.o ntuser/scrollbar.o \ ntuser/windc.o ntuser/prop.o ntuser/scrollbar.o \
ntuser/timer.o ntuser/misc.o ntuser/cleanup.o ntuser/timer.o ntuser/misc.o
OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \ OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \
objects/color.o objects/coord.o objects/dc.o \ objects/color.o objects/coord.o objects/dc.o \

View file

@ -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: class.c,v 1.17 2003/06/16 13:56:09 gvg Exp $ /* $Id: class.c,v 1.18 2003/06/20 16:26:14 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -237,8 +237,6 @@ NtUserRegisterClassExWOW(LPWNDCLASSEXW lpwcx,
NTSTATUS Status; NTSTATUS Status;
RTL_ATOM Atom; RTL_ATOM Atom;
W32kGuiCheck();
DPRINT("About to open window station handle (0x%X)\n", DPRINT("About to open window station handle (0x%X)\n",
PROCESS_WINDOW_STATION()); PROCESS_WINDOW_STATION());

View file

@ -1,88 +0,0 @@
/*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Thread/process cleanup
* FILE: subsys/win32k/ntuser/cleanup.c
* PROGRAMER: Gunnar
* REVISION HISTORY:
*
*/
/* INCLUDES ******************************************************************/
#include <ddk/ntddk.h>
#include <include/timer.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS *****************************************************************/
VOID STDCALL
W32kCreateProcessNotify(
IN HANDLE ParentId,
IN HANDLE ProcessId,
IN BOOLEAN Create
)
{
if (Create){
return;
}
}
VOID STDCALL
W32kCreateThreadNotify(
IN HANDLE ProcessId,
IN HANDLE ThreadId,
IN BOOLEAN Create
)
{
if (Create){
return;
}
RemoveTimersThread(ThreadId);
}
NTSTATUS FASTCALL
InitCleanupImpl()
{
NTSTATUS Status;
Status = PsSetCreateThreadNotifyRoutine(W32kCreateThreadNotify);
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = PsSetCreateProcessNotifyRoutine(W32kCreateProcessNotify,
FALSE);
return Status;
}

View file

@ -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: guicheck.c,v 1.12 2003/05/31 08:53:14 gvg Exp $ /* $Id: guicheck.c,v 1.13 2003/06/20 16:26:14 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -76,52 +76,4 @@ W32kGraphicsCheck(BOOL Create)
} }
VOID FASTCALL
W32kGuiCheck(VOID)
{
if (PsGetWin32Process() == NULL)
{
NTSTATUS Status;
PsCreateWin32Process(PsGetCurrentProcess());
InitializeListHead(&PsGetWin32Process()->ClassListHead);
ExInitializeFastMutex(&PsGetWin32Process()->ClassListLock);
Status =
ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
UserMode,
GENERIC_ALL,
&PsGetWin32Process()->WindowStation);
if (!NT_SUCCESS(Status))
{
DPRINT1("W32K: Failed to reference a window station for "
"process.\n");
}
}
if (PsGetWin32Thread() == NULL)
{
NTSTATUS Status;
PsCreateWin32Thread(PsGetCurrentThread());
PsGetWin32Thread()->MessageQueue = MsqCreateMessageQueue();
InitializeListHead(&PsGetWin32Thread()->WindowListHead);
ExInitializeFastMutex(&PsGetWin32Thread()->WindowListLock);
/* By default threads get assigned their process's desktop. */
PsGetWin32Thread()->Desktop = NULL;
Status = ObReferenceObjectByHandle(PsGetCurrentProcess()->Win32Desktop,
GENERIC_ALL,
ExDesktopObjectType,
UserMode,
(PVOID*)&PsGetWin32Thread()->Desktop,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("W32K: Failed to reference a desktop for thread.\n");
}
}
}
/* EOF */ /* EOF */

View file

@ -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.21 2003/06/14 21:21:23 gvg Exp $ /* $Id: message.c,v 1.22 2003/06/20 16:26:14 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -31,7 +31,6 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <win32k/win32k.h> #include <win32k/win32k.h>
#include <include/guicheck.h>
#include <include/msgqueue.h> #include <include/msgqueue.h>
#include <include/window.h> #include <include/window.h>
#include <include/class.h> #include <include/class.h>
@ -252,9 +251,6 @@ NtUserPeekMessage(LPMSG UnsafeMsg,
BOOL Present; BOOL Present;
PWINDOW_OBJECT Window; PWINDOW_OBJECT Window;
/* Initialize the thread's win32 state if necessary. */
W32kGuiCheck();
/* Validate input */ /* Validate input */
if (NULL != Wnd) if (NULL != Wnd)
{ {
@ -340,9 +336,6 @@ NtUserGetMessage(LPMSG UnsafeMsg,
NTSTATUS Status; NTSTATUS Status;
PWINDOW_OBJECT Window; PWINDOW_OBJECT Window;
/* Initialize the thread's win32 state if necessary. */
W32kGuiCheck();
/* Validate input */ /* Validate input */
if (NULL != Wnd) if (NULL != Wnd)
{ {
@ -412,9 +405,6 @@ NtUserPostMessage(HWND hWnd,
PUSER_MESSAGE Message; PUSER_MESSAGE Message;
NTSTATUS Status; NTSTATUS Status;
/* Initialize the thread's win32 state if necessary. */
W32kGuiCheck();
if (WM_QUIT == Msg) if (WM_QUIT == Msg)
{ {
MsqPostQuitMessage(PsGetWin32Thread()->MessageQueue, wParam); MsqPostQuitMessage(PsGetWin32Thread()->MessageQueue, wParam);
@ -573,8 +563,6 @@ NtUserSendNotifyMessage(HWND hWnd,
BOOL STDCALL BOOL STDCALL
NtUserWaitMessage(VOID) NtUserWaitMessage(VOID)
{ {
/* Initialize the thread's win32 state if necessary. */
W32kGuiCheck();
return W32kWaitMessage(NULL, 0, 0); return W32kWaitMessage(NULL, 0, 0);
} }

View file

@ -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.56 2003/06/16 13:43:16 gvg Exp $ /* $Id: window.c,v 1.57 2003/06/20 16:26:14 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -470,7 +470,6 @@ NtUserCreateWindowEx(DWORD dwExStyle,
DPRINT("NtUserCreateWindowEx\n"); DPRINT("NtUserCreateWindowEx\n");
/* Initialize gui state if necessary. */ /* Initialize gui state if necessary. */
W32kGuiCheck();
W32kGraphicsCheck(TRUE); W32kGraphicsCheck(TRUE);
if (!RtlCreateUnicodeString(&WindowName, if (!RtlCreateUnicodeString(&WindowName,
@ -1150,8 +1149,6 @@ NtUserFindWindowEx(HWND hwndParent,
PLIST_ENTRY currentEntry; PLIST_ENTRY currentEntry;
PWNDCLASS_OBJECT classObject; PWNDCLASS_OBJECT classObject;
W32kGuiCheck();
status = ClassReferenceClassByNameOrAtom(&classObject, ucClassName->Buffer); status = ClassReferenceClassByNameOrAtom(&classObject, ucClassName->Buffer);
if (!NT_SUCCESS(status)) if (!NT_SUCCESS(status))
{ {
@ -1521,8 +1518,6 @@ NtUserGetWindowLong(HWND hWnd, DWORD Index)
NTSTATUS Status; NTSTATUS Status;
LONG Result; LONG Result;
W32kGuiCheck();
Status = Status =
ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable, ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable,
hWnd, hWnd,
@ -1597,8 +1592,6 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
LONG OldValue; LONG OldValue;
STYLESTRUCT Style; STYLESTRUCT Style;
W32kGuiCheck();
Status = Status =
ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable, ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable,
hWnd, hWnd,
@ -1729,8 +1722,6 @@ BOOL STDCALL
NtUserShowWindow(HWND hWnd, NtUserShowWindow(HWND hWnd,
LONG nCmdShow) LONG nCmdShow)
{ {
W32kGuiCheck();
return(WinPosShowWindow(hWnd, nCmdShow)); return(WinPosShowWindow(hWnd, nCmdShow));
} }
@ -1785,4 +1776,5 @@ NtUserGetDesktopWindow()
{ {
return W32kGetDesktopWindow(); return W32kGetDesktopWindow();
} }
/* EOF */ /* EOF */

View file

@ -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: winsta.c,v 1.15 2003/06/16 13:10:01 gvg Exp $ /* $Id: winsta.c,v 1.16 2003/06/20 16:26:14 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -41,7 +41,6 @@
#include <win32k/win32k.h> #include <win32k/win32k.h>
#include <include/winsta.h> #include <include/winsta.h>
#include <include/object.h> #include <include/object.h>
#include <include/guicheck.h>
#include <napi/win32.h> #include <napi/win32.h>
#include <include/class.h> #include <include/class.h>
#include <include/window.h> #include <include/window.h>
@ -787,9 +786,6 @@ NtUserSetThreadDesktop(HDESK hDesktop)
PDESKTOP_OBJECT DesktopObject; PDESKTOP_OBJECT DesktopObject;
NTSTATUS Status; NTSTATUS Status;
/* Initialize the Win32 state if necessary. */
W32kGuiCheck();
/* Validate the new desktop. */ /* Validate the new desktop. */
Status = ValidateDesktopHandle(hDesktop, Status = ValidateDesktopHandle(hDesktop,
KernelMode, KernelMode,
@ -810,7 +806,10 @@ NtUserSetThreadDesktop(HDESK hDesktop)
/* FIXME: Should check here to see if the thread has any windows. */ /* FIXME: Should check here to see if the thread has any windows. */
if (PsGetWin32Thread()->Desktop != NULL)
{
ObDereferenceObject(PsGetWin32Thread()->Desktop); ObDereferenceObject(PsGetWin32Thread()->Desktop);
}
PsGetWin32Thread()->Desktop = DesktopObject; PsGetWin32Thread()->Desktop = DesktopObject;
return(TRUE); return(TRUE);

View file

@ -19,11 +19,12 @@
/* /*
* GDIOBJ.C - GDI object manipulation routines * GDIOBJ.C - GDI object manipulation routines
* *
* $Id: gdiobj.c,v 1.28 2003/06/07 12:37:01 hbirr Exp $ * $Id: gdiobj.c,v 1.29 2003/06/20 16:26:53 ekohl Exp $
* *
*/ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#define WIN32_NO_STATUS
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <include/dce.h> #include <include/dce.h>
@ -590,20 +591,15 @@ BOOL STDCALL W32kDeleteObject(HGDIOBJ hObject)
/*! /*!
* Internal function. Called when the process is destroyed to free the remaining GDI handles. * Internal function. Called when the process is destroyed to free the remaining GDI handles.
* \param Process - PID of the process that was destroyed. * \param Process - PID of the process that will be destroyed.
*/ */
BOOL STDCALL W32kCleanupForProcess(INT Pid) BOOL FASTCALL CleanupForProcess (struct _EPROCESS *Process, INT Pid)
{ {
DWORD i; DWORD i;
PGDI_HANDLE_ENTRY handleEntry; PGDI_HANDLE_ENTRY handleEntry;
PGDIOBJHDR objectHeader; PGDIOBJHDR objectHeader;
NTSTATUS Status; NTSTATUS Status;
PEPROCESS Process;
if (! NT_SUCCESS(PsLookupProcessByProcessId(Pid, &Process)))
{
return FALSE;
}
KeAttachProcess(Process); KeAttachProcess(Process);
for(i = 1; i < GDI_HANDLE_NUMBER; i++) for(i = 1; i < GDI_HANDLE_NUMBER; i++)
@ -619,7 +615,6 @@ BOOL STDCALL W32kCleanupForProcess(INT Pid)
} }
KeDetachProcess(); KeDetachProcess();
ObDereferenceObject(Process);
return TRUE; return TRUE;
} }

View file

@ -1,4 +1,4 @@
; $Id: win32k.def,v 1.15 2003/02/15 19:16:33 gvg Exp $ ; $Id: win32k.def,v 1.16 2003/06/20 16:24:06 ekohl Exp $
; ;
; win32k.def ; win32k.def
; ;
@ -165,7 +165,6 @@ RtlUpcaseUnicodeToMultiByteN@20
STROBJ_bEnum STROBJ_bEnum
STROBJ_dwGetCodePage STROBJ_dwGetCodePage
STROBJ_vEnumStart STROBJ_vEnumStart
W32kCleanupForProcess@4
W32kInitialize W32kInitialize
WNDOBJ_bEnum WNDOBJ_bEnum
WNDOBJ_cEnumStart WNDOBJ_cEnumStart

View file

@ -1,4 +1,4 @@
; $Id: win32k.edf,v 1.9 2003/06/19 17:13:28 gvg Exp $ ; $Id: win32k.edf,v 1.10 2003/06/20 16:24:06 ekohl Exp $
; ;
; win32k.def ; win32k.def
; ;
@ -165,7 +165,6 @@ RtlUpcaseUnicodeToMultiByteN=NTOSKRNL.RtlUpcaseUnicodeToMultiByteN
STROBJ_bEnum STROBJ_bEnum
STROBJ_dwGetCodePage STROBJ_dwGetCodePage
STROBJ_vEnumStart STROBJ_vEnumStart
W32kCleanupForProcess=W32kCleanupForProcess@4
W32kInitialize=W32kInitialize@0 W32kInitialize=W32kInitialize@0
WNDOBJ_bEnum WNDOBJ_bEnum
WNDOBJ_cEnumStart WNDOBJ_cEnumStart