ReactOS 0.4.16-dev-125-g798ea90
stackovf.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for stackovf.c:

Go to the source code of this file.

Classes

struct  _STACK_OVERFLOW_WORK_ITEM
 

Macros

#define NDEBUG
 
#define FSRTLP_MAX_QUEUES   2
 

Typedefs

typedef struct _STACK_OVERFLOW_WORK_ITEM STACK_OVERFLOW_WORK_ITEM
 
typedef struct _STACK_OVERFLOW_WORK_ITEMPSTACK_OVERFLOW_WORK_ITEM
 

Functions

VOID NTAPI FsRtlStackOverflowRead (IN PVOID Context)
 
VOID NTAPI FsRtlpPostStackOverflow (IN PVOID Context, IN PKEVENT Event, IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine, IN BOOLEAN IsPaging)
 
VOID NTAPI FsRtlWorkerThread (IN PVOID StartContext)
 
NTSTATUS NTAPI FsRtlInitializeWorkerThread (VOID)
 
VOID NTAPI FsRtlPostPagingFileStackOverflow (IN PVOID Context, IN PKEVENT Event, IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine)
 
VOID NTAPI FsRtlPostStackOverflow (IN PVOID Context, IN PKEVENT Event, IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine)
 

Variables

KEVENT StackOverflowFallbackSerialEvent
 
STACK_OVERFLOW_WORK_ITEM StackOverflowFallback
 
KQUEUE FsRtlWorkerQueues [FSRTLP_MAX_QUEUES]
 

Macro Definition Documentation

◆ FSRTLP_MAX_QUEUES

#define FSRTLP_MAX_QUEUES   2

Definition at line 23 of file stackovf.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file stackovf.c.

Typedef Documentation

◆ PSTACK_OVERFLOW_WORK_ITEM

◆ STACK_OVERFLOW_WORK_ITEM

Function Documentation

◆ FsRtlInitializeWorkerThread()

NTSTATUS NTAPI FsRtlInitializeWorkerThread ( VOID  )

Definition at line 150 of file stackovf.c.

151{
152 ULONG_PTR i;
154 HANDLE ThreadHandle;
156
157 /* Initialize each queue we have */
158 for (i = 0; i < FSRTLP_MAX_QUEUES; ++i)
159 {
161 NULL,
162 0,
163 NULL,
164 NULL);
165
166 /* Initialize the queue and its associated thread and pass it the queue ID */
169 0, 0, FsRtlWorkerThread, (PVOID)i);
170 if (!NT_SUCCESS(Status))
171 {
172 return Status;
173 }
174
175 /* Don't leak handle */
176 ZwClose(ThreadHandle);
177 }
178
179 /* Also initialize our fallback event, set it to ensure it's already usable */
181
182 return Status;
183}
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
@ SynchronizationEvent
VOID NTAPI KeInitializeQueue(IN PKQUEUE Queue, IN ULONG Count OPTIONAL)
Definition: queue.c:148
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
VOID NTAPI FsRtlWorkerThread(IN PVOID StartContext)
Definition: stackovf.c:113
KQUEUE FsRtlWorkerQueues[FSRTLP_MAX_QUEUES]
Definition: stackovf.c:36
#define FSRTLP_MAX_QUEUES
Definition: stackovf.c:23
KEVENT StackOverflowFallbackSerialEvent
Definition: stackovf.c:34
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by FsRtlInitSystem().

◆ FsRtlPostPagingFileStackOverflow()

VOID NTAPI FsRtlPostPagingFileStackOverflow ( IN PVOID  Context,
IN PKEVENT  Event,
IN PFSRTL_STACK_OVERFLOW_ROUTINE  StackOverflowRoutine 
)

Definition at line 206 of file stackovf.c.

209{
211}
_In_ PKEVENT _In_ PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine
Definition: fsrtlfuncs.h:818
VOID NTAPI FsRtlpPostStackOverflow(IN PVOID Context, IN PKEVENT Event, IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine, IN BOOLEAN IsPaging)
Definition: stackovf.c:76

Referenced by VfatPostRead().

◆ FsRtlPostStackOverflow()

VOID NTAPI FsRtlPostStackOverflow ( IN PVOID  Context,
IN PKEVENT  Event,
IN PFSRTL_STACK_OVERFLOW_ROUTINE  StackOverflowRoutine 
)

Definition at line 232 of file stackovf.c.

235{
237}
#define FALSE
Definition: types.h:117

Referenced by UDFPostStackOverflowRead(), and VfatPostRead().

◆ FsRtlpPostStackOverflow()

VOID NTAPI FsRtlpPostStackOverflow ( IN PVOID  Context,
IN PKEVENT  Event,
IN PFSRTL_STACK_OVERFLOW_ROUTINE  StackOverflowRoutine,
IN BOOLEAN  IsPaging 
)

Definition at line 76 of file stackovf.c.

80{
82
83 /* Try to allocate a work item */
85 if (WorkItem == NULL)
86 {
87 /* If we failed, and we are not a paging file, just raise an error */
88 if (!IsPaging)
89 {
91 }
92
93 /* Otherwise, wait for fallback workitem to be available and use it */
96 }
97
98 /* Initialize work item */
100 WorkItem->Event = Event;
103
104 /* And queue it in the appropriate queue (paging or not?) */
105 KeInsertQueue(&FsRtlWorkerQueues[IsPaging], &WorkItem->WorkItem.List);
106}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define NonPagedPool
Definition: env_spec_w32.h:307
#define KernelMode
Definition: asm.h:34
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
LONG NTAPI KeInsertQueue(IN PKQUEUE Queue, IN PLIST_ENTRY Entry)
Definition: queue.c:198
STACK_OVERFLOW_WORK_ITEM StackOverflowFallback
Definition: stackovf.c:35
VOID NTAPI FsRtlStackOverflowRead(IN PVOID Context)
Definition: stackovf.c:45
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
@ Executive
Definition: ketypes.h:415

Referenced by FsRtlPostPagingFileStackOverflow(), and FsRtlPostStackOverflow().

◆ FsRtlStackOverflowRead()

VOID NTAPI FsRtlStackOverflowRead ( IN PVOID  Context)

Definition at line 45 of file stackovf.c.

46{
48
50
51 /* Put us as top IRP for current thread */
53 /* And call FsRtlSORoutine */
54 WorkItem->Routine(WorkItem->Context, WorkItem->Event);
55
56 /* If we were using fallback workitem, don't free it, just reset event */
58 {
60 }
61 /* Otherwise, free the work item */
62 else
63 {
65 }
66
67 /* Reset top level */
69}
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define FSRTL_FSP_TOP_LEVEL_IRP
Definition: fsrtltypes.h:59
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
struct _STACK_OVERFLOW_WORK_ITEM * PSTACK_OVERFLOW_WORK_ITEM

Referenced by FsRtlpPostStackOverflow().

◆ FsRtlWorkerThread()

VOID NTAPI FsRtlWorkerThread ( IN PVOID  StartContext)

Definition at line 113 of file stackovf.c.

114{
115 KIRQL Irql;
118 ULONG_PTR QueueId = (ULONG_PTR)StartContext;
119
120 /* Set our priority according to the queue we're dealing with */
122
123 /* Loop for events */
124 for (;;)
125 {
126 /* Look for next event */
129
130 /* Call its routine (here: FsRtlStackOverflowRead) */
131 WorkItem->WorkerRoutine(WorkItem->Parameter);
132
133 /* Check we're still at passive level or bugcheck */
135 if (Irql != PASSIVE_LEVEL)
136 {
137 KeBugCheckEx(IRQL_NOT_LESS_OR_EQUAL, (ULONG_PTR)WorkItem->WorkerRoutine,
138 (ULONG_PTR)Irql, (ULONG_PTR)WorkItem->WorkerRoutine,
140 }
141 }
142}
_Out_ PKIRQL Irql
Definition: csq.h:179
#define ULONG_PTR
Definition: config.h:101
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define LOW_REALTIME_PRIORITY
PLIST_ENTRY NTAPI KeRemoveQueue(IN PKQUEUE Queue, IN KPROCESSOR_MODE WaitMode, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: queue.c:238
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1319
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by FsRtlInitializeWorkerThread().

Variable Documentation

◆ FsRtlWorkerQueues

KQUEUE FsRtlWorkerQueues[FSRTLP_MAX_QUEUES]

◆ StackOverflowFallback

STACK_OVERFLOW_WORK_ITEM StackOverflowFallback

Definition at line 35 of file stackovf.c.

Referenced by FsRtlpPostStackOverflow(), and FsRtlStackOverflowRead().

◆ StackOverflowFallbackSerialEvent

KEVENT StackOverflowFallbackSerialEvent