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
W32kDeleteMetaFile 1
W32kDeleteObject 1
W32kCleanupForProcess 1
W32kDescribePixelFormat 4
#W32kDeviceCapabilitiesEx ?
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
#define _INCLUDE_DDK_PSFUNCS_H
@ -41,12 +41,13 @@ NTSTATUS STDCALL PsCreateSystemProcess(PHANDLE ProcessHandle,
NTSTATUS STDCALL PsCreateWin32Process(struct _EPROCESS* Process);
NTSTATUS STDCALL PsCreateWin32Thread(struct _ETHREAD* Thread);
VOID STDCALL PsEstablishWin32Callouts(PVOID Param1,
PVOID Param2,
PVOID Param3,
PVOID Param4,
ULONG W32ThreadSize,
ULONG W32ProcessSize);
VOID STDCALL
PsEstablishWin32Callouts (PW32_PROCESS_CALLBACK W32ProcessCallback,
PW32_THREAD_CALLBACK W32ThreadCallback,
PVOID Param3,
PVOID Param4,
ULONG W32ThreadSize,
ULONG W32ProcessSize);
#define PsGetCurrentProcess() IoGetCurrentProcess()
#define PsGetCurrentThread() ((struct _ETHREAD*) (KeGetCurrentThread()))

View file

@ -23,20 +23,31 @@ struct _KTHREAD;
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,
HANDLE ProcessId,
BOOLEAN Create);
typedef VOID STDCALL_FUNC
(*PCREATE_PROCESS_NOTIFY_ROUTINE)(HANDLE ParentId,
HANDLE ProcessId,
BOOLEAN Create);
typedef VOID STDCALL_FUNC (*PCREATE_THREAD_NOTIFY_ROUTINE)(HANDLE ProcessId,
HANDLE ThreadId,
BOOLEAN Create);
typedef VOID STDCALL_FUNC
(*PCREATE_THREAD_NOTIFY_ROUTINE)(HANDLE ProcessId,
HANDLE ThreadId,
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
{
PVOID BaseAddress;
PVOID UpperAddress;
PVOID BaseAddress;
PVOID UpperAddress;
} STACK_INFORMATION, *PSTACK_INFORMATION;
typedef ULONG THREADINFOCLASS;

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_UnlockMultipleObj( PGDIMULTILOCK pList, INT nObj );
WORD FASTCALL GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle);
VOID STDCALL W32kDumpGdiObjects( INT Process );
BOOL STDCALL W32kCleanupForProcess( INT Process );
VOID STDCALL W32kDumpGdiObjects( INT Pid );
#define GDIOBJFLAG_DEFAULT (0x0)
#define GDIOBJFLAG_IGNOREPID (0x1)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* 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
* PURPOSE: Process manager definitions
@ -522,6 +522,16 @@ PsInitialiseSuspendImplementation(VOID);
extern ULONG PiNrThreadsAwaitingReaping;
NTSTATUS
PsInitWin32Thread (PETHREAD Thread);
VOID
PsTerminateWin32Process (PEPROCESS Process);
VOID
PsTerminateWin32Thread (PETHREAD Thread);
#endif /* ASSEMBLER */
#endif /* __INCLUDE_INTERNAL_PS_H */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* 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
* PURPOSE: 2E trap handler
@ -198,9 +198,14 @@ new_shadowServiceInRange:
movw %bx,%ds
/* Call system call hook */
// pushl %eax
// call _KiSystemCallHook
// popl %eax
/* Call service check routine */
pushl %eax
call _KiSystemCallHook
popl %eax
call _KiServiceCheck
popl %eax
/* Make the system service call */
movl %es:_KeServiceDescriptorTableShadow + 16, %ecx

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
* PROJECT: ReactOS kernel
@ -59,6 +59,30 @@ ULONG KiAfterSystemCallHook(ULONG NtStatus, PKTRAP_FRAME TrapFrame)
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
// TableIndex is 0 based
// 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
;
@ -631,15 +631,14 @@ PsAssignImpersonationToken@8
;PsChargePoolQuota@12
PsCreateSystemProcess@12
PsCreateSystemThread@28
PsCreateWin32Thread@4
PsCreateWin32Process@4
PsGetWin32Thread@0
PsGetWin32Process@0
PsEstablishWin32Callouts@24
PsGetCurrentProcessId@0
PsGetCurrentThreadId@0
PsGetProcessExitTime@0
PsGetVersion@16
PsGetWin32Thread@0
PsGetWin32Process@0
PsImpersonateClient@20
PsInitialSystemProcess DATA
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
;
@ -630,15 +630,14 @@ PsAssignImpersonationToken=PsAssignImpersonationToken@8
;PsChargePoolQuota=PsChargePoolQuota@12
PsCreateSystemProcess=PsCreateSystemProcess@12
PsCreateSystemThread=PsCreateSystemThread@28
PsCreateWin32Thread=PsCreateWin32Thread@4
PsCreateWin32Process=PsCreateWin32Process@4
PsGetWin32Thread=PsGetWin32Thread@0
PsGetWin32Process=PsGetWin32Process@0
PsEstablishWin32Callouts=PsEstablishWin32Callouts@24
PsGetCurrentProcessId=PsGetCurrentProcessId@0
PsGetCurrentThreadId=PsGetCurrentThreadId@0
PsGetProcessExitTime=PsGetProcessExitTime@0
PsGetVersion=PsGetVersion@16
PsGetWin32Thread=PsGetWin32Thread@0
PsGetWin32Process=PsGetWin32Process@0
PsImpersonateClient=PsImpersonateClient@20
PsInitialSystemProcess DATA
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
* PROJECT: ReactOS kernel
@ -286,6 +286,9 @@ PiDeleteThread(PVOID ObjectBody)
DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
/* Terminate Win32 thread */
PsTerminateWin32Thread (Thread);
ObDereferenceObject(Thread->ThreadsProcess);
Thread->ThreadsProcess = NULL;
@ -305,7 +308,7 @@ PiDeleteThread(PVOID ObjectBody)
NotifyRoutine[i](Thread->Cid.UniqueProcess,
Thread->Cid.UniqueThread,
FALSE);
}
}
KeReleaseThread(Thread);
DPRINT("PiDeleteThread() finished\n");

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
* PROJECT: ReactOS kernel
@ -292,25 +292,29 @@ PiDeleteProcess(PVOID ObjectBody)
DPRINT("PiDeleteProcess(ObjectBody %x)\n",ObjectBody);
Process = (PEPROCESS)ObjectBody;
/* Terminate Win32 Process */
PsTerminateWin32Process (Process);
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
NotifyRoutineCount = 0;
for (i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; i++)
{
if (PiProcessNotifyRoutine[i])
{
NotifyRoutine[NotifyRoutineCount++] = PiProcessNotifyRoutine[i];
}
}
{
if (PiProcessNotifyRoutine[i])
{
NotifyRoutine[NotifyRoutineCount++] = PiProcessNotifyRoutine[i];
}
}
RemoveEntryList(&Process->ProcessListEntry);
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
for (i = 0;i < NotifyRoutineCount; i++)
{
//must be called below DISPATCH_LVL
NotifyRoutine[i](Process->InheritedFromUniqueProcessId,
(HANDLE)Process->UniqueProcessId,
FALSE);
}
{
/* must be called below DISPATCH_LVL */
NotifyRoutine[i](Process->InheritedFromUniqueProcessId,
(HANDLE)Process->UniqueProcessId,
FALSE);
}
/* KDB hook */
KDB_DELETEPROCESS_HOOK(Process);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* 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
* PROJECT: ReactOS kernel
@ -37,6 +37,8 @@
/* GLOBALS ******************************************************************/
static PW32_PROCESS_CALLBACK PspWin32ProcessCallback = NULL;
static PW32_THREAD_CALLBACK PspWin32ThreadCallback = NULL;
static ULONG PspWin32ProcessSize = 0;
static ULONG PspWin32ThreadSize = 0;
@ -48,23 +50,6 @@ PsGetWin32Thread(VOID)
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
PsGetWin32Process(VOID)
{
@ -90,15 +75,91 @@ PsCreateWin32Process(PEPROCESS Process)
VOID STDCALL
PsEstablishWin32Callouts(PVOID Param1,
PVOID Param2,
PVOID Param3,
PVOID Param4,
ULONG W32ThreadSize,
ULONG W32ProcessSize)
PsEstablishWin32Callouts (PW32_PROCESS_CALLBACK W32ProcessCallback,
PW32_THREAD_CALLBACK W32ThreadCallback,
PVOID Param3,
PVOID Param4,
ULONG W32ThreadSize,
ULONG W32ProcessSize)
{
PspWin32ProcessCallback = W32ProcessCallback;
PspWin32ThreadCallback = W32ThreadCallback;
PspWin32ProcessSize = W32ProcessSize;
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 */

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
*
@ -18,8 +18,6 @@
#define NDEBUG
#include <debug.h>
BOOL STDCALL W32kCleanupForProcess( INT Process );
#define LOCK RtlEnterCriticalSection(&ProcessDataLock)
#define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock)
@ -120,7 +118,6 @@ NTSTATUS STDCALL CsrFreeProcessData(ULONG Pid)
if (pProcessData)
{
//DbgPrint("CsrFreeProcessData pid: %d\n", Pid);
W32kCleanupForProcess(Pid); //should check if win32k process
if (pProcessData->HandleTable)
{
for( c = 0; c < pProcessData->HandleTableSize; c++ )

View file

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

View file

@ -116,6 +116,8 @@ VOID FASTCALL InitGdiObjectHandleTable (VOID);
VOID FASTCALL CreateStockObjects (VOID);
BOOL FASTCALL CleanupForProcess (struct _EPROCESS *Process, INT Pid);
VOID FASTCALL GDIOBJ_MarkObjectGlobal (HGDIOBJ ObjectHandle);
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
* 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
*/
@ -37,7 +37,6 @@
#include <include/input.h>
#include <include/timer.h>
#include <include/text.h>
#include <include/cleanup.h>
#define NDEBUG
#include <win32k/debug1.h>
@ -46,6 +45,113 @@ extern SSDT Win32kSSDT[];
extern SSPT Win32kSSPT[];
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
*/
@ -63,18 +169,26 @@ DllMain (
* Register user mode call interface
* (system service table index = 1)
*/
Result = KeAddSystemServiceTable (Win32kSSDT, NULL,
Win32kNumberOfSysCalls, Win32kSSPT, 1);
Result = KeAddSystemServiceTable (Win32kSSDT,
NULL,
Win32kNumberOfSysCalls,
Win32kSSPT,
1);
if (Result == FALSE)
{
DbgPrint("Adding system services failed!\n");
return STATUS_UNSUCCESSFUL;
}
{
DbgPrint("Adding system services failed!\n");
return STATUS_UNSUCCESSFUL;
}
/*
* 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();
@ -120,17 +234,9 @@ DllMain (
return(Status);
}
Status = InitCleanupImpl();
if (!NT_SUCCESS(Status))
{
DbgPrint("Failed to initialize cleanup implementation.\n");
return(Status);
}
return STATUS_SUCCESS;
}
PEPROCESS W32kDeviceProcess;
BOOLEAN
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 = ../..
@ -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/winpos.o ntuser/painting.o ntuser/metric.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/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
* 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
* PROJECT: ReactOS kernel
@ -236,8 +236,6 @@ NtUserRegisterClassExWOW(LPWNDCLASSEXW lpwcx,
PWNDCLASS_OBJECT ClassObject;
NTSTATUS Status;
RTL_ATOM Atom;
W32kGuiCheck();
DPRINT("About to open window station handle (0x%X)\n",
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
* 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
* 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 */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* 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
* PROJECT: ReactOS kernel
@ -31,7 +31,6 @@
#include <ddk/ntddk.h>
#include <win32k/win32k.h>
#include <include/guicheck.h>
#include <include/msgqueue.h>
#include <include/window.h>
#include <include/class.h>
@ -252,9 +251,6 @@ NtUserPeekMessage(LPMSG UnsafeMsg,
BOOL Present;
PWINDOW_OBJECT Window;
/* Initialize the thread's win32 state if necessary. */
W32kGuiCheck();
/* Validate input */
if (NULL != Wnd)
{
@ -340,9 +336,6 @@ NtUserGetMessage(LPMSG UnsafeMsg,
NTSTATUS Status;
PWINDOW_OBJECT Window;
/* Initialize the thread's win32 state if necessary. */
W32kGuiCheck();
/* Validate input */
if (NULL != Wnd)
{
@ -412,9 +405,6 @@ NtUserPostMessage(HWND hWnd,
PUSER_MESSAGE Message;
NTSTATUS Status;
/* Initialize the thread's win32 state if necessary. */
W32kGuiCheck();
if (WM_QUIT == Msg)
{
MsqPostQuitMessage(PsGetWin32Thread()->MessageQueue, wParam);
@ -573,8 +563,6 @@ NtUserSendNotifyMessage(HWND hWnd,
BOOL STDCALL
NtUserWaitMessage(VOID)
{
/* Initialize the thread's win32 state if necessary. */
W32kGuiCheck();
return W32kWaitMessage(NULL, 0, 0);
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* 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
* PROJECT: ReactOS kernel
@ -470,7 +470,6 @@ NtUserCreateWindowEx(DWORD dwExStyle,
DPRINT("NtUserCreateWindowEx\n");
/* Initialize gui state if necessary. */
W32kGuiCheck();
W32kGraphicsCheck(TRUE);
if (!RtlCreateUnicodeString(&WindowName,
@ -1150,8 +1149,6 @@ NtUserFindWindowEx(HWND hwndParent,
PLIST_ENTRY currentEntry;
PWNDCLASS_OBJECT classObject;
W32kGuiCheck();
status = ClassReferenceClassByNameOrAtom(&classObject, ucClassName->Buffer);
if (!NT_SUCCESS(status))
{
@ -1521,8 +1518,6 @@ NtUserGetWindowLong(HWND hWnd, DWORD Index)
NTSTATUS Status;
LONG Result;
W32kGuiCheck();
Status =
ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable,
hWnd,
@ -1597,8 +1592,6 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
LONG OldValue;
STYLESTRUCT Style;
W32kGuiCheck();
Status =
ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable,
hWnd,
@ -1729,8 +1722,6 @@ BOOL STDCALL
NtUserShowWindow(HWND hWnd,
LONG nCmdShow)
{
W32kGuiCheck();
return(WinPosShowWindow(hWnd, nCmdShow));
}
@ -1785,4 +1776,5 @@ NtUserGetDesktopWindow()
{
return W32kGetDesktopWindow();
}
/* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* 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
* PROJECT: ReactOS kernel
@ -41,7 +41,6 @@
#include <win32k/win32k.h>
#include <include/winsta.h>
#include <include/object.h>
#include <include/guicheck.h>
#include <napi/win32.h>
#include <include/class.h>
#include <include/window.h>
@ -783,13 +782,10 @@ NtUserResolveDesktopForWOW(DWORD Unknown0)
BOOL STDCALL
NtUserSetThreadDesktop(HDESK hDesktop)
{
{
PDESKTOP_OBJECT DesktopObject;
NTSTATUS Status;
/* Initialize the Win32 state if necessary. */
W32kGuiCheck();
/* Validate the new desktop. */
Status = ValidateDesktopHandle(hDesktop,
KernelMode,
@ -810,7 +806,10 @@ NtUserSetThreadDesktop(HDESK hDesktop)
/* FIXME: Should check here to see if the thread has any windows. */
ObDereferenceObject(PsGetWin32Thread()->Desktop);
if (PsGetWin32Thread()->Desktop != NULL)
{
ObDereferenceObject(PsGetWin32Thread()->Desktop);
}
PsGetWin32Thread()->Desktop = DesktopObject;
return(TRUE);

View file

@ -19,11 +19,12 @@
/*
* 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
#define WIN32_NO_STATUS
#include <windows.h>
#include <ddk/ntddk.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.
* \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;
PGDI_HANDLE_ENTRY handleEntry;
PGDIOBJHDR objectHeader;
NTSTATUS Status;
PEPROCESS Process;
if (! NT_SUCCESS(PsLookupProcessByProcessId(Pid, &Process)))
{
return FALSE;
}
KeAttachProcess(Process);
for(i = 1; i < GDI_HANDLE_NUMBER; i++)
@ -619,7 +615,6 @@ BOOL STDCALL W32kCleanupForProcess(INT Pid)
}
KeDetachProcess();
ObDereferenceObject(Process);
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
;
@ -165,7 +165,6 @@ RtlUpcaseUnicodeToMultiByteN@20
STROBJ_bEnum
STROBJ_dwGetCodePage
STROBJ_vEnumStart
W32kCleanupForProcess@4
W32kInitialize
WNDOBJ_bEnum
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
;
@ -165,7 +165,6 @@ RtlUpcaseUnicodeToMultiByteN=NTOSKRNL.RtlUpcaseUnicodeToMultiByteN
STROBJ_bEnum
STROBJ_dwGetCodePage
STROBJ_vEnumStart
W32kCleanupForProcess=W32kCleanupForProcess@4
W32kInitialize=W32kInitialize@0
WNDOBJ_bEnum
WNDOBJ_cEnumStart