ReactOS  0.4.14-dev-342-gdc047f9
framebased.c File Reference
#include <windows.h>
#include <pseh/pseh.h>
#include <pseh/framebased/internal.h>
#include <pseh/excpt.h>
#include <pseh/framebased.h>
#include <excpt.h>
Include dependency graph for framebased.c:

Go to the source code of this file.

Macros

#define _NTSYSTEM_
 
#define STRICT
 
#define WIN32_LEAN_AND_MEAN
 
#define _SEH_TRACE_ENTER(FRAME_, FUNCNAME_, ARGS_)
 
#define _SEH_TRACE_LEAVE(FRAME_, FUNCNAME_, ARGS_)
 
#define _SEH_TRACE_EXCEPTION_RECORD(FRAME_, ER_)
 
#define _SEH_TRACE_CONTEXT(FRAME_, CONTEXT_)
 
#define _SEH_TRACE_UNWIND(FRAME_, ARGS_)
 
#define _SEH_TRACE_TRYLEVEL(FRAME_, TRYLEVEL_)
 
#define _SEH_TRACE_ENTER_CALL_FILTER(FRAME_, TRYLEVEL_, ER_)
 
#define _SEH_TRACE_LEAVE_CALL_FILTER(FRAME_, TRYLEVEL_, RET_)
 
#define _SEH_TRACE_FILTER(FRAME_, TRYLEVEL_, RET_)
 
#define _SEH_TRACE_ENTER_CALL_HANDLER(FRAME_, TRYLEVEL_)
 
#define _SEH_TRACE_ENTER_CALL_FINALLY(FRAME_, TRYLEVEL_)
 
#define _SEH_TRACE_LEAVE_CALL_FINALLY(FRAME_, TRYLEVEL_)
 

Functions

void __cdecl _SEHCleanHandlerEnvironment (void)
 
struct __SEHRegistration *__cdecl _SEHRegisterFrame (_SEHRegistration_t *)
 
void __cdecl _SEHUnregisterFrame (void)
 
void __cdecl _SEHGlobalUnwind (_SEHPortableFrame_t *)
 
_SEHRegistration_t *__cdecl _SEHCurrentRegistration (void)
 
void __stdcall RtlUnwind (void *, void *, PEXCEPTION_RECORD, void *)
 
static void __stdcall _SEHLocalUnwind (_SEHPortableFrame_t *frame, _SEHPortableTryLevel_t *dsttrylevel)
 
static void __cdecl _SEHCallHandler (_SEHPortableFrame_t *frame, _SEHPortableTryLevel_t *trylevel)
 
static int __cdecl _SEHFrameHandler (struct _EXCEPTION_RECORD *ExceptionRecord, void *EstablisherFrame, struct _CONTEXT *ContextRecord, void *DispatcherContext)
 
void __stdcall _SEHEnterFrame_s (_SEHPortableFrame_t *frame)
 
void __stdcall _SEHLeaveFrame_s (void)
 
void __stdcall _SEHReturn_s (void)
 
void _SEH_FASTCALL _SEHEnterFrame_f (_SEHPortableFrame_t *frame)
 
void _SEH_FASTCALL _SEHLeaveFrame_f (void)
 
void _SEH_FASTCALL _SEHReturn_f (void)
 

Variables

void const_SEHRtlUnwind = RtlUnwind
 

Macro Definition Documentation

◆ _NTSYSTEM_

#define _NTSYSTEM_

Definition at line 23 of file framebased.c.

◆ _SEH_TRACE_CONTEXT

#define _SEH_TRACE_CONTEXT (   FRAME_,
  CONTEXT_ 
)

Definition at line 266 of file framebased.c.

◆ _SEH_TRACE_ENTER

#define _SEH_TRACE_ENTER (   FRAME_,
  FUNCNAME_,
  ARGS_ 
)

Definition at line 263 of file framebased.c.

◆ _SEH_TRACE_ENTER_CALL_FILTER

#define _SEH_TRACE_ENTER_CALL_FILTER (   FRAME_,
  TRYLEVEL_,
  ER_ 
)

Definition at line 269 of file framebased.c.

◆ _SEH_TRACE_ENTER_CALL_FINALLY

#define _SEH_TRACE_ENTER_CALL_FINALLY (   FRAME_,
  TRYLEVEL_ 
)

Definition at line 273 of file framebased.c.

◆ _SEH_TRACE_ENTER_CALL_HANDLER

#define _SEH_TRACE_ENTER_CALL_HANDLER (   FRAME_,
  TRYLEVEL_ 
)

Definition at line 272 of file framebased.c.

◆ _SEH_TRACE_EXCEPTION_RECORD

#define _SEH_TRACE_EXCEPTION_RECORD (   FRAME_,
  ER_ 
)

Definition at line 265 of file framebased.c.

◆ _SEH_TRACE_FILTER

#define _SEH_TRACE_FILTER (   FRAME_,
  TRYLEVEL_,
  RET_ 
)

Definition at line 271 of file framebased.c.

◆ _SEH_TRACE_LEAVE

#define _SEH_TRACE_LEAVE (   FRAME_,
  FUNCNAME_,
  ARGS_ 
)

Definition at line 264 of file framebased.c.

◆ _SEH_TRACE_LEAVE_CALL_FILTER

#define _SEH_TRACE_LEAVE_CALL_FILTER (   FRAME_,
  TRYLEVEL_,
  RET_ 
)

Definition at line 270 of file framebased.c.

◆ _SEH_TRACE_LEAVE_CALL_FINALLY

#define _SEH_TRACE_LEAVE_CALL_FINALLY (   FRAME_,
  TRYLEVEL_ 
)

Definition at line 274 of file framebased.c.

◆ _SEH_TRACE_TRYLEVEL

#define _SEH_TRACE_TRYLEVEL (   FRAME_,
  TRYLEVEL_ 
)

Definition at line 268 of file framebased.c.

◆ _SEH_TRACE_UNWIND

#define _SEH_TRACE_UNWIND (   FRAME_,
  ARGS_ 
)

Definition at line 267 of file framebased.c.

◆ STRICT

#define STRICT

Definition at line 24 of file framebased.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 25 of file framebased.c.

Function Documentation

◆ _SEHCallHandler()

static void __cdecl _SEHCallHandler ( _SEHPortableFrame_t frame,
_SEHPortableTryLevel_t trylevel 
)
static

Definition at line 323 of file framebased.c.

327 {
328  _SEHGlobalUnwind(frame);
329  _SEHLocalUnwind(frame, trylevel);
330  _SEH_TRACE_ENTER_CALL_HANDLER(frame, trylevel);
331  frame->SPF_Handler(trylevel);
332  /* ASSERT(0); */
333 }
void __cdecl _SEHGlobalUnwind(_SEHPortableFrame_t *)
static void __stdcall _SEHLocalUnwind(_SEHPortableFrame_t *frame, _SEHPortableTryLevel_t *dsttrylevel)
Definition: framebased.c:289
volatile _SEHHandler_t SPF_Handler
Definition: internal.h:99
#define _SEH_TRACE_ENTER_CALL_HANDLER(FRAME_, TRYLEVEL_)
Definition: framebased.c:272

Referenced by _SEHFrameHandler().

◆ _SEHCleanHandlerEnvironment()

void __cdecl _SEHCleanHandlerEnvironment ( void  )

Referenced by _SEHFrameHandler().

◆ _SEHCurrentRegistration()

_SEHRegistration_t* __cdecl _SEHCurrentRegistration ( void  )

Referenced by _SEHReturn_f().

◆ _SEHEnterFrame_f()

void _SEH_FASTCALL _SEHEnterFrame_f ( _SEHPortableFrame_t frame)

Definition at line 462 of file framebased.c.

463 {
464  /* ASSERT(frame); */
465  /* ASSERT(trylevel); */
466  frame->SPF_Registration.SER_Handler = _SEHFrameHandler;
467  frame->SPF_Code = 0;
469 }
struct __SEHRegistration *__cdecl _SEHRegisterFrame(_SEHRegistration_t *)
_SEHRegistration_t SPF_Registration
Definition: internal.h:97
static int __cdecl _SEHFrameHandler(struct _EXCEPTION_RECORD *ExceptionRecord, void *EstablisherFrame, struct _CONTEXT *ContextRecord, void *DispatcherContext)
Definition: framebased.c:336
unsigned long SPF_Code
Definition: internal.h:98

Referenced by _SEHEnterFrame_s().

◆ _SEHEnterFrame_s()

void __stdcall _SEHEnterFrame_s ( _SEHPortableFrame_t frame)

Definition at line 447 of file framebased.c.

448 {
449  _SEHEnterFrame_f(frame);
450 }
void _SEH_FASTCALL _SEHEnterFrame_f(_SEHPortableFrame_t *frame)
Definition: framebased.c:462

◆ _SEHFrameHandler()

static int __cdecl _SEHFrameHandler ( struct _EXCEPTION_RECORD ExceptionRecord,
void EstablisherFrame,
struct _CONTEXT ContextRecord,
void DispatcherContext 
)
static

Definition at line 336 of file framebased.c.

342 {
343  _SEHPortableFrame_t * frame;
344 
346 
347  frame = EstablisherFrame;
348 
350  (
351  frame,
352  "_SEHFrameHandler",
353  (
354  "%p, %p, %p, %p",
355  ExceptionRecord,
359  )
360  );
361 
362  _SEH_TRACE_EXCEPTION_RECORD(frame, ExceptionRecord);
364 
365  /* Unwinding */
366  if(ExceptionRecord->ExceptionFlags & (4 | 2))
367  {
368  _SEH_TRACE_UNWIND(frame, ("enter forced unwind"));
369  _SEHLocalUnwind(frame, NULL);
370  _SEH_TRACE_UNWIND(frame, ("leave forced unwind"));
371  }
372  /* Handling */
373  else
374  {
375  int ret;
376  _SEHPortableTryLevel_t * trylevel;
377 
378  if(ExceptionRecord->ExceptionCode)
379  frame->SPF_Code = ExceptionRecord->ExceptionCode;
380  else
381  frame->SPF_Code = 0xC0000001;
382 
383  for
384  (
385  trylevel = frame->SPF_TopTryLevel;
386  trylevel != NULL;
387  trylevel = trylevel->SPT_Next
388  )
389  {
390  _SEHFilter_t pfnFilter = trylevel->SPT_Handlers.SH_Filter;
391 
392  _SEH_TRACE_TRYLEVEL(frame, trylevel);
393 
394  switch((UINT_PTR)pfnFilter)
395  {
399  {
400  ret = (int)((UINT_PTR)pfnFilter) - 2;
401  break;
402  }
403 
404  default:
405  {
406  if(trylevel->SPT_Handlers.SH_Filter)
407  {
409 
410  ep.ExceptionRecord = ExceptionRecord;
412 
413  _SEH_TRACE_ENTER_CALL_FILTER(frame, trylevel, ExceptionRecord);
414  ret = pfnFilter(&ep, frame);
415  _SEH_TRACE_LEAVE_CALL_FILTER(frame, trylevel, ret);
416  }
417  else
419 
420  break;
421  }
422  }
423 
424  _SEH_TRACE_FILTER(frame, trylevel, ret);
425 
426  /* _SEH_CONTINUE_EXECUTION */
427  if(ret < 0)
428  {
429  _SEH_TRACE_LEAVE(frame, "_SEHFrameHandler", ("ExceptionContinueExecution"));
431  }
432  /* _SEH_EXECUTE_HANDLER */
433  else if(ret > 0)
434  _SEHCallHandler(frame, trylevel);
435  /* _SEH_CONTINUE_SEARCH */
436  else
437  continue;
438  }
439 
440  /* FALLTHROUGH */
441  }
442 
443  _SEH_TRACE_LEAVE(frame, "_SEHFrameHandler", ("ExceptionContinueSearch"));
445 }
_IRQL_requires_same_ _In_ PVOID EstablisherFrame
Definition: ntbasedef.h:660
volatile _SEHHandlers_t SPT_Handlers
Definition: internal.h:91
void __cdecl _SEHCleanHandlerEnvironment(void)
struct __SEHPortableTryLevel *volatile SPT_Next
Definition: internal.h:90
#define _SEH_TRACE_ENTER_CALL_FILTER(FRAME_, TRYLEVEL_, ER_)
Definition: framebased.c:269
#define _SEH_CONTINUE_SEARCH
Definition: excpt.h:27
static void __stdcall _SEHLocalUnwind(_SEHPortableFrame_t *frame, _SEHPortableTryLevel_t *dsttrylevel)
Definition: framebased.c:289
#define _SEH_STATIC_FILTER(ACTION_)
Definition: framebased.h:112
#define _SEH_TRACE_CONTEXT(FRAME_, CONTEXT_)
Definition: framebased.c:266
#define _SEH_TRACE_EXCEPTION_RECORD(FRAME_, ER_)
Definition: framebased.c:265
DWORD ExceptionCode
Definition: compat.h:196
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT _In_ PVOID DispatcherContext
Definition: ntbasedef.h:661
#define _SEH_TRACE_LEAVE(FRAME_, FUNCNAME_, ARGS_)
Definition: framebased.c:264
smooth NULL
Definition: ftsmooth.c:416
PCONTEXT ContextRecord
Definition: rtltypes.h:197
static void __cdecl _SEHCallHandler(_SEHPortableFrame_t *frame, _SEHPortableTryLevel_t *trylevel)
Definition: framebased.c:323
_SEHFilter_t SH_Filter
Definition: internal.h:83
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define _SEH_TRACE_ENTER(FRAME_, FUNCNAME_, ARGS_)
Definition: framebased.c:263
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT * ContextRecord
Definition: ntbasedef.h:661
#define _SEH_TRACE_LEAVE_CALL_FILTER(FRAME_, TRYLEVEL_, RET_)
Definition: framebased.c:270
int ret
#define _SEH_EXECUTE_HANDLER
Definition: excpt.h:28
#define _SEH_TRACE_TRYLEVEL(FRAME_, TRYLEVEL_)
Definition: framebased.c:268
#define _SEH_CONTINUE_EXECUTION
Definition: excpt.h:26
#define _SEH_TRACE_FILTER(FRAME_, TRYLEVEL_, RET_)
Definition: framebased.c:271
DWORD ExceptionFlags
Definition: compat.h:197
PEXCEPTION_RECORD ExceptionRecord
Definition: rtltypes.h:196
_SEHPortableTryLevel_t *volatile SPF_TopTryLevel
Definition: internal.h:100
unsigned long SPF_Code
Definition: internal.h:98
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define _SEH_TRACE_UNWIND(FRAME_, ARGS_)
Definition: framebased.c:267

Referenced by _SEHEnterFrame_f().

◆ _SEHGlobalUnwind()

void __cdecl _SEHGlobalUnwind ( _SEHPortableFrame_t )

Referenced by _SEHCallHandler().

◆ _SEHLeaveFrame_f()

void _SEH_FASTCALL _SEHLeaveFrame_f ( void  )

Definition at line 471 of file framebased.c.

472 {
473  /* _SEHPortableFrame_t * frame;
474 
475  frame = _SEH_CONTAINING_RECORD
476  (
477  _SEHCurrentRegistration(),
478  _SEHPortableFrame_t,
479  SPF_Registration
480  ); */
481 
482  /* ASSERT(frame); */
483  /* ASSERT(frame->SPF_TopTryLevel == NULL) */
484 
486 }
void __cdecl _SEHUnregisterFrame(void)

Referenced by _SEHLeaveFrame_s().

◆ _SEHLeaveFrame_s()

void __stdcall _SEHLeaveFrame_s ( void  )

Definition at line 452 of file framebased.c.

453 {
455 }
void _SEH_FASTCALL _SEHLeaveFrame_f(void)
Definition: framebased.c:471

◆ _SEHLocalUnwind()

static void __stdcall _SEHLocalUnwind ( _SEHPortableFrame_t frame,
_SEHPortableTryLevel_t dsttrylevel 
)
static

Definition at line 289 of file framebased.c.

293 {
294  _SEHPortableTryLevel_t * trylevel;
295 
296  _SEH_TRACE_UNWIND(frame, ("enter local unwind from %p to %p", frame->SPF_TopTryLevel, dsttrylevel));
297 
298  for
299  (
300  trylevel = frame->SPF_TopTryLevel;
301  trylevel != dsttrylevel;
302  trylevel = trylevel->SPT_Next
303  )
304  {
305  _SEHFinally_t pfnFinally;
306 
307  /* ASSERT(trylevel); */
308 
309  pfnFinally = trylevel->SPT_Handlers.SH_Finally;
310 
311  if(pfnFinally)
312  {
313  _SEH_TRACE_ENTER_CALL_FINALLY(frame, trylevel);
314  pfnFinally(frame);
315  _SEH_TRACE_LEAVE_CALL_FINALLY(frame, trylevel);
316  }
317  }
318 
319  _SEH_TRACE_UNWIND(frame, ("leave local unwind from %p to %p", frame->SPF_TopTryLevel, dsttrylevel));
320 }
volatile _SEHHandlers_t SPT_Handlers
Definition: internal.h:91
struct __SEHPortableTryLevel *volatile SPT_Next
Definition: internal.h:90
#define _SEH_TRACE_LEAVE_CALL_FINALLY(FRAME_, TRYLEVEL_)
Definition: framebased.c:274
void(__stdcall * _SEHFinally_t)(struct __SEHPortableFrame *)
Definition: internal.h:77
#define _SEH_TRACE_ENTER_CALL_FINALLY(FRAME_, TRYLEVEL_)
Definition: framebased.c:273
_SEHFinally_t SH_Finally
Definition: internal.h:84
_SEHPortableTryLevel_t *volatile SPF_TopTryLevel
Definition: internal.h:100
#define _SEH_TRACE_UNWIND(FRAME_, ARGS_)
Definition: framebased.c:267

Referenced by _SEHCallHandler(), _SEHFrameHandler(), and _SEHReturn_f().

◆ _SEHRegisterFrame()

struct __SEHRegistration* __cdecl _SEHRegisterFrame ( _SEHRegistration_t )

Referenced by _SEHEnterFrame_f().

◆ _SEHReturn_f()

void _SEH_FASTCALL _SEHReturn_f ( void  )

Definition at line 488 of file framebased.c.

489 {
490  _SEHPortableFrame_t * frame;
491 
492  frame = _SEH_CONTAINING_RECORD
493  (
496  SPF_Registration
497  );
498 
499  _SEHLocalUnwind(frame, NULL);
501 }
void __cdecl _SEHUnregisterFrame(void)
static void __stdcall _SEHLocalUnwind(_SEHPortableFrame_t *frame, _SEHPortableTryLevel_t *dsttrylevel)
Definition: framebased.c:289
smooth NULL
Definition: ftsmooth.c:416
#define _SEH_CONTAINING_RECORD(ADDR_, TYPE_, FIELD_)
Definition: pseh.h:43
_SEHRegistration_t *__cdecl _SEHCurrentRegistration(void)

Referenced by _SEHReturn_s().

◆ _SEHReturn_s()

void __stdcall _SEHReturn_s ( void  )

Definition at line 457 of file framebased.c.

458 {
459  _SEHReturn_f();
460 }
void _SEH_FASTCALL _SEHReturn_f(void)
Definition: framebased.c:488

◆ _SEHUnregisterFrame()

void __cdecl _SEHUnregisterFrame ( void  )

Referenced by _SEHLeaveFrame_f(), and _SEHReturn_f().

◆ RtlUnwind()

void __stdcall RtlUnwind ( void ,
void ,
PEXCEPTION_RECORD  ,
void  
)

Variable Documentation

◆ _SEHRtlUnwind

void const* _SEHRtlUnwind = RtlUnwind

Definition at line 286 of file framebased.c.