ReactOS 0.4.15-dev-7842-g558ab78
win32.c File Reference
#include <ntoskrnl.h>
#include <winerror.h>
#include <debug.h>
Include dependency graph for win32.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI PsConvertToGuiThread (VOID)
 
VOID NTAPI PsEstablishWin32Callouts (IN PWIN32_CALLOUTS_FPNS CalloutData)
 

Variables

PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout = NULL
 
PKWIN32_THREAD_CALLOUT PspW32ThreadCallout = NULL
 
PGDI_BATCHFLUSH_ROUTINE KeGdiFlushUserBatch = NULL
 
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectParse
 
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectDelete
 
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectOkToClose
 
PKWIN32_SESSION_CALLOUT ExpDesktopObjectOkToClose
 
PKWIN32_SESSION_CALLOUT ExpDesktopObjectDelete
 
PKWIN32_SESSION_CALLOUT ExpDesktopObjectOpen
 
PKWIN32_SESSION_CALLOUT ExpDesktopObjectClose
 
PKWIN32_POWEREVENT_CALLOUT PopEventCallout
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file win32.c.

Function Documentation

◆ PsConvertToGuiThread()

NTSTATUS NTAPI PsConvertToGuiThread ( VOID  )

Definition at line 34 of file win32.c.

35{
36 ULONG_PTR NewStack;
37 PVOID OldStack;
41 PAGED_CODE();
42
43 /* Validate the previous mode */
45
46 /* If no win32k, crashes later */
48
49 /* Make sure win32k is here */
51
52 /* Make sure it's not already win32 */
54 {
55 /* We're already a win32 thread */
57 }
58
59 /* Check if we don't already have a kernel-mode stack */
60 if (!Thread->Tcb.LargeStack)
61 {
62 /* We don't create one */
63 NewStack = (ULONG_PTR)MmCreateKernelStack(TRUE, 0);
64 if (!NewStack)
65 {
66 /* Panic in user-mode */
67 NtCurrentTeb()->LastErrorValue = ERROR_NOT_ENOUGH_MEMORY;
68 return STATUS_NO_MEMORY;
69 }
70
71 /* We're about to switch stacks. Enter a guarded region */
73
74 /* Switch stacks */
75 OldStack = KeSwitchKernelStack((PVOID)NewStack,
76 (PVOID)(NewStack - KERNEL_STACK_SIZE));
77
78 /* Leave the guarded region */
80
81 /* Delete the old stack */
82 MmDeleteKernelStack(OldStack, FALSE);
83 }
84
85 /* Always do the process callout! */
87 if (!NT_SUCCESS(Status)) return Status;
88
89 /* Set the new service table */
92
93 /* Tell Win32k about our thread */
95 if (!NT_SUCCESS(Status))
96 {
97 /* Revert our table */
99 }
100
101 /* Return status */
102 return Status;
103}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ULONG_PTR
Definition: config.h:101
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
Status
Definition: gdiplustypes.h:25
@ PsW32ThreadCalloutInitialize
Definition: pstypes.h:499
#define NtCurrentTeb
#define KeLeaveGuardedRegion()
Definition: ke_x.h:68
#define KeEnterGuardedRegion()
Definition: ke_x.h:39
#define ASSERT(a)
Definition: mode.c:44
#define KernelMode
Definition: asm.h:34
#define KeGetPreviousMode()
Definition: ketypes.h:1115
PVOID NTAPI KeSwitchKernelStack(IN PVOID StackBase, IN PVOID StackLimit)
VOID NTAPI MmDeleteKernelStack(PVOID Stack, BOOLEAN GuiStack)
PVOID NTAPI MmCreateKernelStack(BOOLEAN GuiStack, UCHAR Node)
PKWIN32_THREAD_CALLOUT PspW32ThreadCallout
Definition: win32.c:19
PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout
Definition: win32.c:18
#define STATUS_ALREADY_WIN32
Definition: ntstatus.h:141
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[SSDT_MAX_ENTRIES]
Definition: procobj.c:23
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES]
Definition: procobj.c:24
#define KERNEL_STACK_SIZE
KTHREAD Tcb
Definition: pstypes.h:1103
PVOID Win32Thread
Definition: ketypes.h:1866
PVOID ServiceTable
Definition: ketypes.h:1671
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define PsGetCurrentProcess
Definition: psfuncs.h:17

◆ PsEstablishWin32Callouts()

VOID NTAPI PsEstablishWin32Callouts ( IN PWIN32_CALLOUTS_FPNS  CalloutData)

Definition at line 112 of file win32.c.

113{
114 /* Setup the callback pointers */
115 PspW32ProcessCallout = CalloutData->ProcessCallout;
116 PspW32ThreadCallout = CalloutData->ThreadCallout;
117 ExpWindowStationObjectParse = CalloutData->WindowStationParseProcedure;
118 ExpWindowStationObjectDelete = CalloutData->WindowStationDeleteProcedure;
119 ExpWindowStationObjectOkToClose = CalloutData->WindowStationOkToCloseProcedure;
120 ExpDesktopObjectOkToClose = CalloutData->DesktopOkToCloseProcedure;
121 ExpDesktopObjectDelete = CalloutData->DesktopDeleteProcedure;
122 ExpDesktopObjectOpen = CalloutData->DesktopOpenProcedure;
123 ExpDesktopObjectClose = CalloutData->DesktopCloseProcedure;
124 PopEventCallout = CalloutData->PowerEventCallout;
125 KeGdiFlushUserBatch = CalloutData->BatchFlushRoutine;
126}
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectDelete
Definition: win32k.c:41
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectParse
Definition: win32k.c:40
PKWIN32_SESSION_CALLOUT ExpDesktopObjectDelete
Definition: win32k.c:44
PKWIN32_SESSION_CALLOUT ExpDesktopObjectClose
Definition: win32k.c:46
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectOkToClose
Definition: win32k.c:42
PKWIN32_SESSION_CALLOUT ExpDesktopObjectOpen
Definition: win32k.c:45
PKWIN32_SESSION_CALLOUT ExpDesktopObjectOkToClose
Definition: win32k.c:43
PKWIN32_POWEREVENT_CALLOUT PopEventCallout
Definition: events.c:32
PGDI_BATCHFLUSH_ROUTINE KeGdiFlushUserBatch
Definition: win32.c:20

Referenced by DriverEntry().

Variable Documentation

◆ ExpDesktopObjectClose

PKWIN32_SESSION_CALLOUT ExpDesktopObjectClose
extern

Definition at line 46 of file win32k.c.

Referenced by ExpDesktopClose(), and PsEstablishWin32Callouts().

◆ ExpDesktopObjectDelete

PKWIN32_SESSION_CALLOUT ExpDesktopObjectDelete
extern

Definition at line 44 of file win32k.c.

Referenced by ExpDesktopDelete(), and PsEstablishWin32Callouts().

◆ ExpDesktopObjectOkToClose

PKWIN32_SESSION_CALLOUT ExpDesktopObjectOkToClose
extern

Definition at line 43 of file win32k.c.

Referenced by ExpDesktopOkToClose(), and PsEstablishWin32Callouts().

◆ ExpDesktopObjectOpen

PKWIN32_SESSION_CALLOUT ExpDesktopObjectOpen
extern

Definition at line 45 of file win32k.c.

Referenced by ExpDesktopOpen(), and PsEstablishWin32Callouts().

◆ ExpWindowStationObjectDelete

PKWIN32_SESSION_CALLOUT ExpWindowStationObjectDelete
extern

Definition at line 41 of file win32k.c.

Referenced by ExpWinStaObjectDelete(), and PsEstablishWin32Callouts().

◆ ExpWindowStationObjectOkToClose

PKWIN32_SESSION_CALLOUT ExpWindowStationObjectOkToClose
extern

Definition at line 42 of file win32k.c.

Referenced by ExpWindowStationOkToClose(), and PsEstablishWin32Callouts().

◆ ExpWindowStationObjectParse

PKWIN32_SESSION_CALLOUT ExpWindowStationObjectParse
extern

Definition at line 40 of file win32k.c.

Referenced by ExpWinStaObjectParse(), and PsEstablishWin32Callouts().

◆ KeGdiFlushUserBatch

◆ PopEventCallout

PKWIN32_POWEREVENT_CALLOUT PopEventCallout
extern

Definition at line 32 of file events.c.

Referenced by PoNotifySystemTimeSet(), and PsEstablishWin32Callouts().

◆ PspW32ProcessCallout

PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout = NULL

Definition at line 18 of file win32.c.

Referenced by PsConvertToGuiThread(), PsEstablishWin32Callouts(), and PspExitThread().

◆ PspW32ThreadCallout

PKWIN32_THREAD_CALLOUT PspW32ThreadCallout = NULL

Definition at line 19 of file win32.c.

Referenced by PsConvertToGuiThread(), PsEstablishWin32Callouts(), and PspExitThread().