ReactOS 0.4.16-dev-401-g45b008d
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 _NTSYSTEM_
 
#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

◆ _NTSYSTEM_

#define _NTSYSTEM_

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 6 of file gs_support.c.

◆ 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

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{
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 */
151 abort();
152}
#define __MINGW_ATTRIB_UNUSED
Definition: _mingw.h:124
#define NULL
Definition: types.h:112
#define GetCurrentProcess()
Definition: compat.h:759
LONG WINAPI UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: except.c:269
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI DECLSPEC_HOTPATCH SetUnhandledExceptionFilter(IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
Definition: except.c:790
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
#define UNW_FLAG_NHANDLER
Definition: gs_support.c:32
static EXCEPTION_RECORD GS_ExceptionRecord
Definition: gs_support.c:41
static CONTEXT GS_ContextRecord
Definition: gs_support.c:42
DECLSPEC_SELECTANY UINT_PTR __security_cookie_complement
Definition: gs_support.c:50
DECLSPEC_SELECTANY UINT_PTR __security_cookie
Definition: gs_support.c:49
static const EXCEPTION_POINTERS GS_ExceptionPointers
Definition: gs_support.c:44
#define abort()
Definition: i386-dis.c:34
#define _ReturnAddress()
Definition: intrin_arm.h:35
#define _AddressOfReturnAddress()
Definition: intrin_ppc.h:40
unsigned __int64 ULONG64
Definition: imports.h:198
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
#define DWORD
Definition: nt_native.h:44
#define STATUS_STACK_BUFFER_OVERRUN
Definition: ntstatus.h:946
ULONG Esp
Definition: nt_native.h:1479
ULONG Ecx
Definition: nt_native.h:1467
ULONG Eip
Definition: nt_native.h:1476
DWORD ExceptionCode
Definition: compat.h:208
DWORD ExceptionFlags
Definition: compat.h:209
PVOID ExceptionAddress
Definition: compat.h:211
Definition: cookie.c:34
#define EXCEPTION_NONCONTINUABLE
Definition: stubs.h:23
void * PVOID
Definition: typedefs.h:50
uint64_t ULONGLONG
Definition: typedefs.h:67
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_opt_ PKNONVOLATILE_CONTEXT_POINTERS ContextPointers)
Definition: unwind.c:478
PRUNTIME_FUNCTION NTAPI RtlLookupFunctionEntry(IN DWORD64 ControlPc, OUT PDWORD64 ImageBase, OUT PUNWIND_HISTORY_TABLE HistoryTable)
Locates the RUNTIME_FUNCTION entry corresponding to a code address. http://msdn.microsoft....
Definition: unwind.c:124

◆ __security_init_cookie()

void __cdecl __security_init_cookie ( void  )

Definition at line 55 of file gs_support.c.

56{
58 FT systime = { 0, };
59 LARGE_INTEGER perfctr;
60
62 {
63 __security_cookie_complement = ~__security_cookie;
64 return;
65 }
66
68#ifdef _WIN64
69 cookie = systime.ft_scalar;
70#else
73#endif
74
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
95}
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define DEFAULT_SECURITY_COOKIE
Definition: gs_support.c:25
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: gs_support.c:35
unsigned __int64 ft_scalar
Definition: gs_support.c:36
FILETIME ft_struct
Definition: gs_support.c:37
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158

Referenced by _IRQL_requires_max_().

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:

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.