ReactOS  0.4.13-dev-235-g7373cb3
gs_support.c File Reference
#include <stdlib.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <ntstatus.h>
Include dependency graph for gs_support.c:

Go to the source code of this file.

Classes

union  FT
 

Macros

#define WIN32_LEAN_AND_MEAN
 
#define WIN32_NO_STATUS
 
#define DEFAULT_SECURITY_COOKIE   0xBB40E64E
 
#define UNW_FLAG_NHANDLER   0x00
 

Typedefs

typedef LONG NTSTATUS
 

Functions

void __cdecl __security_init_cookie (void)
 
 __declspec (noreturn)
 

Variables

static EXCEPTION_RECORD GS_ExceptionRecord
 
static CONTEXT GS_ContextRecord
 
static const EXCEPTION_POINTERS GS_ExceptionPointers
 
DECLSPEC_SELECTANY UINT_PTR __security_cookie = DEFAULT_SECURITY_COOKIE
 
DECLSPEC_SELECTANY UINT_PTR __security_cookie_complement = ~(DEFAULT_SECURITY_COOKIE)
 

Macro Definition Documentation

◆ DEFAULT_SECURITY_COOKIE

#define DEFAULT_SECURITY_COOKIE   0xBB40E64E

Definition at line 25 of file gs_support.c.

◆ UNW_FLAG_NHANDLER

#define UNW_FLAG_NHANDLER   0x00

Definition at line 32 of file gs_support.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 8 of file gs_support.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file gs_support.c.

Typedef Documentation

◆ NTSTATUS

typedef LONG NTSTATUS

Definition at line 30 of file gs_support.c.

Function Documentation

◆ __declspec()

__declspec ( noreturn  )

Definition at line 105 of file gs_support.c.

110 {
111  volatile UINT_PTR cookie[2] __MINGW_ATTRIB_UNUSED;
112 #ifdef _WIN64
113  ULONG64 controlPC, imgBase, establisherFrame;
114  PRUNTIME_FUNCTION fctEntry;
115  PVOID hndData;
116 
118  controlPC = GS_ContextRecord.Rip;
119  fctEntry = RtlLookupFunctionEntry (controlPC, &imgBase, NULL);
120  if (fctEntry != NULL)
121  {
122  RtlVirtualUnwind (UNW_FLAG_NHANDLER, imgBase, controlPC, fctEntry,
123  &GS_ContextRecord, &hndData, &establisherFrame, NULL);
124  }
125  else
126 #endif /* _WIN64 */
127  {
128 #ifdef _WIN64
131 #else
134 #endif /* _WIN64 */
135  }
136 
137 #ifdef _WIN64
139  GS_ContextRecord.Rcx = StackCookie;
140 #else
142  GS_ContextRecord.Ecx = StackCookie;
143 #endif /* _WIN64 */
146  cookie[0] = __security_cookie;
147  cookie[1] = __security_cookie_complement;
151  abort();
152 }
ULONG Esp
Definition: nt_native.h:1479
ULONG Eip
Definition: nt_native.h:1476
ULONG Ecx
Definition: nt_native.h:1467
#define EXCEPTION_NONCONTINUABLE
Definition: rtltypes.h:150
void * _AddressOfReturnAddress(void)
PEXCEPTION_ROUTINE NTAPI RtlVirtualUnwind(_In_ ULONG HandlerType, _In_ ULONG64 ImageBase, _In_ ULONG64 ControlPc, _In_ PRUNTIME_FUNCTION FunctionEntry, _Inout_ PCONTEXT Context, _Outptr_ PVOID *HandlerData, _Out_ PULONG64 EstablisherFrame, _Inout_ PKNONVOLATILE_CONTEXT_POINTERS ContextPointers)
Definition: unwind.c:349
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
#define DWORD
Definition: nt_native.h:44
PVOID ExceptionAddress
Definition: compat.h:199
DWORD ExceptionCode
Definition: compat.h:196
#define STATUS_STACK_BUFFER_OVERRUN
Definition: ntstatus.h:932
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI DECLSPEC_HOTPATCH SetUnhandledExceptionFilter(IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
Definition: except.c:792
LONG WINAPI UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: except.c:262
static const EXCEPTION_POINTERS GS_ExceptionPointers
Definition: gs_support.c:44
static EXCEPTION_RECORD GS_ExceptionRecord
Definition: gs_support.c:41
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(ULONG_PTR, DWORD *, UNWIND_HISTORY_TABLE *)
uint64_t ULONGLONG
Definition: typedefs.h:65
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
#define __MINGW_ATTRIB_UNUSED
Definition: _mingw.h:122
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned __int64 ULONG64
Definition: imports.h:198
DECLSPEC_SELECTANY UINT_PTR __security_cookie_complement
Definition: gs_support.c:50
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1562
#define abort()
Definition: i386-dis.c:35
static CONTEXT GS_ContextRecord
Definition: gs_support.c:42
void * _ReturnAddress(void)
DWORD ExceptionFlags
Definition: compat.h:197
DECLSPEC_SELECTANY UINT_PTR __security_cookie
Definition: gs_support.c:49
#define UNW_FLAG_NHANDLER
Definition: gs_support.c:32

◆ __security_init_cookie()

void __cdecl __security_init_cookie ( void  )

Definition at line 55 of file gs_support.c.

56 {
57  UINT_PTR cookie;
58  FT systime = { 0, };
59  LARGE_INTEGER perfctr;
60 
62  {
64  return;
65  }
66 
68 #ifdef _WIN64
69  cookie = systime.ft_scalar;
70 #else
71  cookie = systime.ft_struct.dwLowDateTime;
72  cookie ^= systime.ft_struct.dwHighDateTime;
73 #endif
74 
75  cookie ^= GetCurrentProcessId ();
76  cookie ^= GetCurrentThreadId ();
77  cookie ^= GetTickCount ();
78 
79  QueryPerformanceCounter (&perfctr);
80 #ifdef _WIN64
81  cookie ^= perfctr.QuadPart;
82 #else
83  cookie ^= perfctr.LowPart;
84  cookie ^= perfctr.HighPart;
85 #endif
86 
87 #ifdef _WIN64
88  cookie &= 0x0000ffffffffffffll;
89 #endif
90 
91  if (cookie == DEFAULT_SECURITY_COOKIE)
92  cookie = DEFAULT_SECURITY_COOKIE + 1;
93  __security_cookie = cookie;
95 }
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
FILETIME ft_struct
Definition: gs_support.c:37
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define DEFAULT_SECURITY_COOKIE
Definition: gs_support.c:25
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
DECLSPEC_SELECTANY UINT_PTR __security_cookie_complement
Definition: gs_support.c:50
ULONG LowPart
Definition: typedefs.h:104
Definition: gs_support.c:34
w ll
Definition: byte_order.h:166
unsigned __int64 ft_scalar
Definition: gs_support.c:36
DWORD dwLowDateTime
Definition: mapidefs.h:65
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1188
LONGLONG QuadPart
Definition: typedefs.h:112
DECLSPEC_SELECTANY UINT_PTR __security_cookie
Definition: gs_support.c:49

Referenced by mainCRTStartup(), and WinMainCRTStartup().

Variable Documentation

◆ __security_cookie

Definition at line 49 of file gs_support.c.

Referenced by __security_init_cookie().

◆ __security_cookie_complement

DECLSPEC_SELECTANY UINT_PTR __security_cookie_complement = ~(DEFAULT_SECURITY_COOKIE)

Definition at line 50 of file gs_support.c.

Referenced by __security_init_cookie().

◆ GS_ContextRecord

CONTEXT GS_ContextRecord
static

Definition at line 42 of file gs_support.c.

◆ GS_ExceptionPointers

const EXCEPTION_POINTERS GS_ExceptionPointers
static
Initial value:
= {
}
static EXCEPTION_RECORD GS_ExceptionRecord
Definition: gs_support.c:41
static CONTEXT GS_ContextRecord
Definition: gs_support.c:42

Definition at line 44 of file gs_support.c.

◆ GS_ExceptionRecord

EXCEPTION_RECORD GS_ExceptionRecord
static

Definition at line 41 of file gs_support.c.