Changeset 97866 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Dec 26, 2022 2:14:08 AM (2 years ago)
- Location:
- trunk/src/VBox/Runtime/common/compiler/vcc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/compiler/vcc/except-x86-vcc-asm.asm
r97862 r97866 86 86 BEGINCODE 87 87 extern IMPNAME(RtlUnwind@16) 88 89 90 88 extern _rtVccEh4DoLocalUnwindHandler@16 89 90 91 ;********************************************************************************************************************************* 92 ;* Global Variables * 93 ;********************************************************************************************************************************* 94 95 ;; Delcare rtVccEh4DoLocalUnwindHandler() in except-x86.cpp as a save exception handler. 96 ; This adds the symbol table number of the exception handler to the special .sxdata section. 97 safeseh _rtVccEh4DoLocalUnwindHandler@16 98 99 100 BEGINCODE 91 101 ;; 92 102 ; Calls the filter sub-function for a __finally statement. -
trunk/src/VBox/Runtime/common/compiler/vcc/except-x86-vcc.cpp
r97863 r97866 39 39 * Header Files * 40 40 *********************************************************************************************************************************/ 41 #include <iprt/win/windows.h> 42 41 #include <iprt/nt/nt-and-windows.h> 42 43 #include "internal/compiler-vcc.h" 43 44 #include "except-vcc.h" 45 46 47 /********************************************************************************************************************************* 48 * Structures and Typedefs * 49 *********************************************************************************************************************************/ 50 /** 51 * Extended exception registration record used by rtVccEh4DoLocalUnwind 52 * and rtVccEh4DoLocalUnwindHandler. 53 */ 54 typedef struct EH4_LOCAL_UNWIND_XCPT_REG 55 { 56 /** Security cookie. */ 57 uintptr_t uEHCookieFront; 58 /** The actual registration record. */ 59 EXCEPTION_REGISTRATION_RECORD XcptRegRec; 60 /** @name rtVccEh4DoLocalUnwind parameters 61 * @{ */ 62 PEH4_XCPT_REG_REC_T pEh4XcptRegRec; 63 uint32_t uTargetTryLevel; 64 uint8_t const *pbFrame; 65 /** @} */ 66 /** Security cookie. */ 67 uintptr_t uEHCookieBack; 68 } EH4_LOCAL_UNWIND_XCPT_REG; 69 44 70 45 71 … … 57 83 DECLASM(void) rtVccEh4DoGlobalUnwind(PEXCEPTION_RECORD pXcptRec, PEXCEPTION_REGISTRATION_RECORD pXcptRegRec); 58 84 DECLASM(void) rtVccEh4DoFinally(PFN_EH4_FINALLY_T pfnFinally, bool fAbend, uint8_t const *pbFrame); 59 85 extern "C" EXCEPTION_DISPOSITION __stdcall 86 rtVccEh4DoLocalUnwindHandler(PEXCEPTION_RECORD pXcptRec, PVOID pvEstFrame, PCONTEXT pCpuCtx, PVOID pvDispCtx); 87 88 89 #ifdef _MSC_VER 90 # pragma warning(push) 91 # pragma warning(disable:4733) /* warning C4733: Inline asm assigning to 'FS:0': handler not registered as safe handler */ 92 #endif 60 93 61 94 /** … … 72 105 * Manually set up exception handler. 73 106 */ 74 /** @todo */ 107 EH4_LOCAL_UNWIND_XCPT_REG RegRec = 108 { 109 __security_cookie ^ (uintptr_t)&RegRec, 110 { 111 (EXCEPTION_REGISTRATION_RECORD *)__readfsdword(RT_UOFFSETOF(NT_TIB, ExceptionList)), 112 rtVccEh4DoLocalUnwindHandler /* safeseh (.sxdata) entry emitted by except-x86-vcc-asm.asm */ 113 }, 114 pEh4XcptRegRec, 115 uTargetTryLevel, 116 pbFrame, 117 __security_cookie ^ (uintptr_t)&RegRec 118 }; 119 __writefsdword(RT_UOFFSETOF(NT_TIB, ExceptionList), (uintptr_t)&RegRec.XcptRegRec); 75 120 76 121 /* … … 101 146 * Deregister exception handler. 102 147 */ 103 /** @todo */ 104 } 105 106 148 __writefsdword(RT_UOFFSETOF(NT_TIB, ExceptionList), (uintptr_t)RegRec.XcptRegRec.Next); 149 } 150 151 #ifdef _MSC_VER 152 # pragma warning(pop) 153 #endif 154 155 /** 156 * Exception handler for rtVccEh4DoLocalUnwind. 157 */ 158 EXCEPTION_DISPOSITION __stdcall 159 rtVccEh4DoLocalUnwindHandler(PEXCEPTION_RECORD pXcptRec, PVOID pvEstFrame, PCONTEXT pCpuCtx, PVOID pvDispCtx) 160 { 161 EH4_LOCAL_UNWIND_XCPT_REG *pMyRegRec = RT_FROM_MEMBER(pvEstFrame, EH4_LOCAL_UNWIND_XCPT_REG, XcptRegRec); 162 __security_check_cookie(pMyRegRec->uEHCookieFront ^ (uintptr_t)pMyRegRec); 163 __security_check_cookie(pMyRegRec->uEHCookieBack ^ (uintptr_t)pMyRegRec); 164 165 /* 166 * This is a little sketchy as it isn't all that well documented by the OS 167 * vendor, but if invoked while unwinding, we return ExceptionCollidedUnwind 168 * and update the *ppDispCtx value to point to the colliding one. 169 */ 170 if (pXcptRec->ExceptionFlags & (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND)) 171 { 172 rtVccEh4DoLocalUnwind(pMyRegRec->pEh4XcptRegRec, pMyRegRec->uTargetTryLevel, pMyRegRec->pbFrame); 173 174 PEXCEPTION_REGISTRATION_RECORD *ppDispCtx = (PEXCEPTION_REGISTRATION_RECORD *)pvDispCtx; 175 *ppDispCtx = &pMyRegRec->XcptRegRec; 176 return ExceptionCollidedUnwind; 177 } 178 179 /* 180 * In all other cases we do nothing special. 181 */ 182 RT_NOREF(pCpuCtx); 183 return ExceptionContinueSearch; 184 } 185 186 187 /** 188 * This validates the CPU context, may terminate the application if invalid. 189 */ 107 190 DECLINLINE(void) rtVccValidateExceptionContextRecord(PCONTEXT pCpuCtx) 108 191 { 109 RT_NOREF(pCpuCtx); 110 /** @todo Implement __exception_validate_context_record .*/ 192 if (RT_LIKELY( !rtVccIsGuardICallChecksActive() 193 || rtVccIsPointerOnTheStack(pCpuCtx->Esp))) 194 { /* likely */ } 195 else 196 rtVccCheckContextFailed(pCpuCtx); 111 197 } 112 198 -
trunk/src/VBox/Runtime/common/compiler/vcc/loadcfg-vcc.c
r96407 r97866 56 56 extern uint8_t __safe_se_handler_count; /**< Absolute "address" defined by the linker representing the table size. */ 57 57 #endif 58 extern uintptr_t __guard_check_icall_fptr; /**< nocrt-guard-win.asm */59 58 #ifdef RT_ARCH_AMD64 60 59 extern uintptr_t __guard_dispatch_icall_fptr;/**< nocrt-guard-win.asm */ -
trunk/src/VBox/Runtime/common/compiler/vcc/stacksup-vcc.cpp
r96580 r97866 329 329 } 330 330 331 332 void rtVccCheckContextFailed(PCONTEXT pCpuCtx) 333 { 334 #ifdef IPRT_NOCRT_WITHOUT_FATAL_WRITE 335 RTAssertMsg2("\n\n!!Context (stack) check failed!!\n\n" 336 "PC=%p SP=%p BP=%p\n", 337 # ifdef RT_ARCH_AMD64 338 pCpuCtx->Rip, pCpuCtx->Rsp, pCpuCtx->Rbp 339 # elif defined(RT_ARCH_X86) 340 pCpuCtx->Eip, pCpuCtx->Esp, pCpuCtx->Ebp 341 # else 342 # error "unsupported arch" 343 # endif 344 ); 345 #else 346 rtNoCrtFatalWriteBegin(RT_STR_TUPLE("\r\n\r\n!!Context (stack) check failed!!\r\n\r\n" 347 "PC=")); 348 # ifdef RT_ARCH_AMD64 349 rtNoCrtFatalWritePtr((void *)pCpuCtx->Rip); 350 # elif defined(RT_ARCH_X86) 351 rtNoCrtFatalWritePtr((void *)pCpuCtx->Eip); 352 # else 353 # error "unsupported arch" 354 # endif 355 rtNoCrtFatalWrite(RT_STR_TUPLE(" SP=")); 356 # ifdef RT_ARCH_AMD64 357 rtNoCrtFatalWritePtr((void *)pCpuCtx->Rsp); 358 # elif defined(RT_ARCH_X86) 359 rtNoCrtFatalWritePtr((void *)pCpuCtx->Esp); 360 # endif 361 rtNoCrtFatalWrite(RT_STR_TUPLE(" BP=")); 362 # ifdef RT_ARCH_AMD64 363 rtNoCrtFatalWritePtr((void *)pCpuCtx->Rbp); 364 # elif defined(RT_ARCH_X86) 365 rtNoCrtFatalWritePtr((void *)pCpuCtx->Ebp); 366 # endif 367 rtNoCrtFatalWriteEnd(RT_STR_TUPLE("\r\n")); 368 #endif 369 rtVccFatalSecurityErrorWithCtx(FAST_FAIL_INVALID_SET_OF_CONTEXT, pCpuCtx); 370 } 371
Note:
See TracChangeset
for help on using the changeset viewer.