3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: win32.c,v 1.9 2004/09/28 15:02:29 weiden Exp $
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: ntoskrnl/ps/win32.c
24 * PURPOSE: win32k support
25 * PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
30 /* INCLUDES ****************************************************************/
34 /* TYPES *******************************************************************/
36 /* GLOBALS ******************************************************************/
38 static PW32_PROCESS_CALLBACK PspWin32ProcessCallback
= NULL
;
39 static PW32_THREAD_CALLBACK PspWin32ThreadCallback
= NULL
;
40 static ULONG PspWin32ProcessSize
= 0;
41 static ULONG PspWin32ThreadSize
= 0;
43 /* FUNCTIONS ***************************************************************/
46 PsGetWin32Thread(VOID
)
48 return(PsGetCurrentThread()->Tcb
.Win32Thread
);
52 PsGetWin32Process(VOID
)
54 return(PsGetCurrentProcess()->Win32Process
);
58 PsCreateWin32Process(PEPROCESS Process
)
60 if (Process
->Win32Process
!= NULL
)
61 return(STATUS_SUCCESS
);
63 Process
->Win32Process
= ExAllocatePool(NonPagedPool
,
65 if (Process
->Win32Process
== NULL
)
66 return(STATUS_NO_MEMORY
);
68 RtlZeroMemory(Process
->Win32Process
,
71 return(STATUS_SUCCESS
);
79 PsEstablishWin32Callouts (PW32_PROCESS_CALLBACK W32ProcessCallback
,
80 PW32_THREAD_CALLBACK W32ThreadCallback
,
86 PspWin32ProcessCallback
= W32ProcessCallback
;
87 PspWin32ThreadCallback
= W32ThreadCallback
;
89 PspWin32ProcessSize
= W32ProcessSize
;
90 PspWin32ThreadSize
= W32ThreadSize
;
95 PsInitWin32Thread (PETHREAD Thread
)
99 Process
= Thread
->ThreadsProcess
;
101 if (Process
->Win32Process
== NULL
)
103 Process
->Win32Process
= ExAllocatePool (NonPagedPool
,
104 PspWin32ProcessSize
);
105 if (Process
->Win32Process
== NULL
)
106 return STATUS_NO_MEMORY
;
108 RtlZeroMemory (Process
->Win32Process
,
109 PspWin32ProcessSize
);
111 if (PspWin32ProcessCallback
!= NULL
)
113 PspWin32ProcessCallback (Process
, TRUE
);
117 if (Thread
->Tcb
.Win32Thread
== NULL
)
119 Thread
->Tcb
.Win32Thread
= ExAllocatePool (NonPagedPool
,
121 if (Thread
->Tcb
.Win32Thread
== NULL
)
122 return STATUS_NO_MEMORY
;
124 RtlZeroMemory (Thread
->Tcb
.Win32Thread
,
127 if (PspWin32ThreadCallback
!= NULL
)
129 PspWin32ThreadCallback (Thread
, TRUE
);
133 return(STATUS_SUCCESS
);
138 PsTerminateWin32Process (PEPROCESS Process
)
140 if (Process
->Win32Process
== NULL
)
143 if (PspWin32ProcessCallback
!= NULL
)
145 PspWin32ProcessCallback (Process
, FALSE
);
148 ExFreePool (Process
->Win32Process
);
153 PsTerminateWin32Thread (PETHREAD Thread
)
155 if (Thread
->Tcb
.Win32Thread
!= NULL
)
157 if (PspWin32ThreadCallback
!= NULL
)
159 PspWin32ThreadCallback (Thread
, FALSE
);
162 ExFreePool (Thread
->Tcb
.Win32Thread
);