VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/compiler/vcc/except-vcc.h@ 96420

Last change on this file since 96420 was 96420, checked in by vboxsync, 3 years ago

IPRT/nocrt: Implemented GSHandlerCheck so we can avoid overrunning the stack due to the int3 in the stub. bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/* $Id: except-vcc.h 96420 2022-08-23 02:14:54Z vboxsync $ */
2/** @file
3 * IPRT - Visual C++ Compiler - Exception Management.
4 */
5
6/*
7 * Copyright (C) 2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.215389.xyz.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_SRC_common_compiler_vcc_except_vcc_h
38#define IPRT_INCLUDED_SRC_common_compiler_vcc_except_vcc_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43
44#include <iprt/types.h>
45#include <iprt/assertcompile.h>
46
47#if 0
48/** This is part of the AMD64 and ARM (?) exception interface, but appear to
49 * live in the runtime headers for some weird reason. */
50typedef enum
51{
52 ExceptionContinueExecution = 0,
53 ExceptionContinueSearch,
54 ExceptionNestedException,
55 ExceptionCollidedUnwind
56} EXCEPTION_DISPOSITION;
57#endif
58
59/* The following two are borrowed from pecoff.h, as we typically want to include
60 winnt.h with this header and the two header cannot co-exist. */
61
62/**
63 * An unwind code for AMD64 and ARM64.
64 *
65 * @note Also known as UNWIND_CODE or _UNWIND_CODE.
66 */
67typedef union IMAGE_UNWIND_CODE
68{
69 struct
70 {
71 /** The prolog offset where the change takes effect.
72 * This means the instruction following the one being described. */
73 uint8_t CodeOffset;
74 /** Unwind opcode.
75 * For AMD64 see IMAGE_AMD64_UNWIND_OP_CODES. */
76 RT_GCC_EXTENSION uint8_t UnwindOp : 4;
77 /** Opcode specific. */
78 RT_GCC_EXTENSION uint8_t OpInfo : 4;
79 } u;
80 uint16_t FrameOffset;
81} IMAGE_UNWIND_CODE;
82AssertCompileSize(IMAGE_UNWIND_CODE, 2);
83
84/**
85 * Unwind information for AMD64 and ARM64.
86 *
87 * Pointed to by IMAGE_RUNTIME_FUNCTION_ENTRY::UnwindInfoAddress,
88 *
89 * @note Also known as UNWIND_INFO or _UNWIND_INFO.
90 */
91typedef struct IMAGE_UNWIND_INFO
92{
93 /** Version, currently 1 or 2. The latter if IMAGE_AMD64_UWOP_EPILOG is used. */
94 RT_GCC_EXTENSION uint8_t Version : 3;
95 /** IMAGE_UNW_FLAG_XXX */
96 RT_GCC_EXTENSION uint8_t Flags : 5;
97 /** Size of function prolog. */
98 uint8_t SizeOfProlog;
99 /** Number of opcodes in aOpcodes. */
100 uint8_t CountOfCodes;
101 /** Initial frame register. */
102 RT_GCC_EXTENSION uint8_t FrameRegister : 4;
103 /** Scaled frame register offset. */
104 RT_GCC_EXTENSION uint8_t FrameOffset : 4;
105 /** Unwind opcodes. */
106 RT_FLEXIBLE_ARRAY_EXTENSION
107 IMAGE_UNWIND_CODE aOpcodes[RT_FLEXIBLE_ARRAY];
108} IMAGE_UNWIND_INFO;
109AssertCompileMemberOffset(IMAGE_UNWIND_INFO, aOpcodes, 4);
110typedef IMAGE_UNWIND_INFO *PIMAGE_UNWIND_INFO;
111typedef IMAGE_UNWIND_INFO const *PCIMAGE_UNWIND_INFO;
112
113
114
115#ifdef RT_ARCH_AMD64
116
117/**
118 * The Visual C++ 2019 layout of the GS_HANDLER_DATA data type for AMD64.
119 *
120 * This is pointed to by DISPATCHER_CONTEXT::HandlerData when dispatching
121 * exceptions. The data resides after the unwind info for the function.
122 */
123typedef struct _GS_HANDLER_DATA
124{
125 union
126 {
127 struct
128 {
129 uint32_t fEHandler : 1;
130#define GS_HANDLER_OFF_COOKIE_IS_EHANDLER RT_BIT(0)
131 uint32_t fUHandler : 1;
132#define GS_HANDLER_OFF_COOKIE_IS_UHANDLER RT_BIT(1)
133 uint32_t fHasAlignment : 1;
134#define GS_HANDLER_OFF_COOKIE_HAS_ALIGNMENT RT_BIT(2)
135 } Bits;
136#define GS_HANDLER_OFF_COOKIE_MASK UINT32_C(0xfffffff8) /**< Mask to apply to offCookie to the the value. */
137 uint32_t offCookie;
138 } u;
139 int32_t offAlignedBase;
140 uint32_t uAlignmentMask;
141} GS_HANDLER_DATA;
142typedef GS_HANDLER_DATA *PGS_HANDLER_DATA;
143typedef GS_HANDLER_DATA const *PCGS_HANDLER_DATA;
144#endif
145
146#ifdef RT_ARCH_X86
147void __fastcall __security_check_cookie(uintptr_t uCookieToCheck);
148#else
149void __cdecl __security_check_cookie(uintptr_t uCookieToCheck);
150#endif
151
152#endif /* !IPRT_INCLUDED_SRC_common_compiler_vcc_except_vcc_h */
153
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette