ReactOS 0.4.17-dev-806-gffa4164
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
 
PKWIN32_JOB_CALLOUT PspW32JobCallout = 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 35 of file win32.c.

36{
37 ULONG_PTR NewStack;
38 PVOID OldStack;
42 PAGED_CODE();
43
44 /* Validate the previous mode */
46
47 /* If no win32k, crashes later */
49
50 /* Make sure win32k is here */
52
53 /* Make sure it's not already win32 */
55 {
56 /* We're already a win32 thread */
58 }
59
60 /* Check if we don't already have a kernel-mode stack */
61 if (!Thread->Tcb.LargeStack)
62 {
63 /* We don't create one */
64 NewStack = (ULONG_PTR)MmCreateKernelStack(TRUE, 0);
65 if (!NewStack)
66 {
67 /* Panic in user-mode */
68 NtCurrentTeb()->LastErrorValue = ERROR_NOT_ENOUGH_MEMORY;
69 return STATUS_NO_MEMORY;
70 }
71
72 /* We're about to switch stacks. Enter a guarded region */
74
75 /* Switch stacks */
76 OldStack = KeSwitchKernelStack((PVOID)NewStack,
77 (PVOID)(NewStack - KERNEL_STACK_SIZE));
78
79 /* Leave the guarded region */
81
82 /* Delete the old stack */
83 MmDeleteKernelStack(OldStack, FALSE);
84 }
85
86 /* Always do the process callout! */
88 if (!NT_SUCCESS(Status)) return Status;
89
90 /* Set the new service table */
93
94 /* Tell Win32k about our thread */
96 if (!NT_SUCCESS(Status))
97 {
98 /* Revert our table */
100 }
101
102 /* Return status */
103 return Status;
104}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#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:33
#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:24
@ PsW32ThreadCalloutInitialize
Definition: pstypes.h:563
#define NtCurrentTeb
#define KeLeaveGuardedRegion()
Definition: ke_x.h:68
#define KeEnterGuardedRegion()
Definition: ke_x.h:39
#define ASSERT(a)
Definition: mode.c:44
#define KeGetPreviousMode()
Definition: ketypes.h:1115
#define KernelMode
Definition: asm.h:38
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:216
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:1228
PVOID Win32Thread
Definition: ketypes.h:2013
PVOID ServiceTable
Definition: ketypes.h:1818
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 113 of file win32.c.

114{
115 /* Setup the callback pointers */
116 PspW32ProcessCallout = CalloutData->ProcessCallout;
117 PspW32ThreadCallout = CalloutData->ThreadCallout;
118 PspW32JobCallout = CalloutData->JobCallout;
119 ExpWindowStationObjectParse = CalloutData->WindowStationParseProcedure;
120 ExpWindowStationObjectDelete = CalloutData->WindowStationDeleteProcedure;
121 ExpWindowStationObjectOkToClose = CalloutData->WindowStationOkToCloseProcedure;
122 ExpDesktopObjectOkToClose = CalloutData->DesktopOkToCloseProcedure;
123 ExpDesktopObjectDelete = CalloutData->DesktopDeleteProcedure;
124 ExpDesktopObjectOpen = CalloutData->DesktopOpenProcedure;
125 ExpDesktopObjectClose = CalloutData->DesktopCloseProcedure;
126 PopEventCallout = CalloutData->PowerEventCallout;
127 KeGdiFlushUserBatch = CalloutData->BatchFlushRoutine;
128}
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:21
PKWIN32_JOB_CALLOUT PspW32JobCallout
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().

◆ PspW32JobCallout

PKWIN32_JOB_CALLOUT PspW32JobCallout = NULL

Definition at line 20 of file win32.c.

Referenced by PsEstablishWin32Callouts(), and PspInvokeW32JobCallout().

◆ 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().