ReactOS  0.4.13-dev-540-g8f04a09
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 */
56  return STATUS_ALREADY_WIN32;
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 TRUE
Definition: types.h:120
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PVOID ServiceTable
Definition: ketypes.h:1561
VOID NTAPI MmDeleteKernelStack(PVOID Stack, BOOLEAN GuiStack)
PVOID NTAPI KeSwitchKernelStack(IN PVOID StackBase, IN PVOID StackLimit)
#define KeGetPreviousMode()
Definition: ketypes.h:1081
LONG NTSTATUS
Definition: precomp.h:26
KTHREAD Tcb
Definition: pstypes.h:1034
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define PAGED_CODE()
Definition: video.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PsGetCurrentProcess
Definition: psfuncs.h:17
PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout
Definition: win32.c:18
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES]
Definition: procobj.c:24
smooth NULL
Definition: ftsmooth.c:416
#define KeLeaveGuardedRegion()
Definition: ke_x.h:63
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define KERNEL_STACK_SIZE
#define KeEnterGuardedRegion()
Definition: ke_x.h:34
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define STATUS_ALREADY_WIN32
Definition: ntstatus.h:141
PKWIN32_THREAD_CALLOUT PspW32ThreadCallout
Definition: win32.c:19
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[SSDT_MAX_ENTRIES]
Definition: procobj.c:23
PVOID Win32Thread
Definition: ketypes.h:1756
#define ULONG_PTR
Definition: config.h:101
PVOID NTAPI MmCreateKernelStack(BOOLEAN GuiStack, UCHAR Node)

◆ 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 }
PGDI_BATCHFLUSH_ROUTINE KeGdiFlushUserBatch
Definition: win32.c:20
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectOkToClose
Definition: win32k.c:46
PKWIN32_POWEREVENT_CALLOUT PopEventCallout
Definition: events.c:32
PKWIN32_SESSION_CALLOUT ExpDesktopObjectDelete
Definition: win32k.c:48
PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout
Definition: win32.c:18
PKWIN32_SESSION_CALLOUT ExpDesktopObjectClose
Definition: win32k.c:50
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectDelete
Definition: win32k.c:45
PKWIN32_THREAD_CALLOUT PspW32ThreadCallout
Definition: win32.c:19
PKWIN32_SESSION_CALLOUT ExpWindowStationObjectParse
Definition: win32k.c:44
PKWIN32_SESSION_CALLOUT ExpDesktopObjectOpen
Definition: win32k.c:49
PKWIN32_SESSION_CALLOUT ExpDesktopObjectOkToClose
Definition: win32k.c:47

Referenced by DriverEntry().

Variable Documentation

◆ ExpDesktopObjectClose

PKWIN32_SESSION_CALLOUT ExpDesktopObjectClose

Definition at line 50 of file win32k.c.

Referenced by ExpDesktopClose(), and PsEstablishWin32Callouts().

◆ ExpDesktopObjectDelete

PKWIN32_SESSION_CALLOUT ExpDesktopObjectDelete

Definition at line 48 of file win32k.c.

Referenced by ExpDesktopDelete(), and PsEstablishWin32Callouts().

◆ ExpDesktopObjectOkToClose

PKWIN32_SESSION_CALLOUT ExpDesktopObjectOkToClose

Definition at line 47 of file win32k.c.

Referenced by ExpDesktopOkToClose(), and PsEstablishWin32Callouts().

◆ ExpDesktopObjectOpen

PKWIN32_SESSION_CALLOUT ExpDesktopObjectOpen

Definition at line 49 of file win32k.c.

Referenced by ExpDesktopOpen(), and PsEstablishWin32Callouts().

◆ ExpWindowStationObjectDelete

PKWIN32_SESSION_CALLOUT ExpWindowStationObjectDelete

Definition at line 45 of file win32k.c.

Referenced by ExpWinStaObjectDelete(), and PsEstablishWin32Callouts().

◆ ExpWindowStationObjectOkToClose

PKWIN32_SESSION_CALLOUT ExpWindowStationObjectOkToClose

Definition at line 46 of file win32k.c.

Referenced by ExpWindowStationOkToClose(), and PsEstablishWin32Callouts().

◆ ExpWindowStationObjectParse

PKWIN32_SESSION_CALLOUT ExpWindowStationObjectParse

Definition at line 44 of file win32k.c.

Referenced by ExpWinStaObjectParse(), and PsEstablishWin32Callouts().

◆ KeGdiFlushUserBatch

PGDI_BATCHFLUSH_ROUTINE KeGdiFlushUserBatch = NULL

Definition at line 20 of file win32.c.

Referenced by KeUserModeCallback(), KiSystemServiceHandler(), and PsEstablishWin32Callouts().

◆ PopEventCallout

PKWIN32_POWEREVENT_CALLOUT PopEventCallout

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